KickJava   Java API By Example, From Geeks To Geeks.

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


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.net.URLEncoder JavaDoc;
27 import java.util.ArrayList 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.ContentVersionController;
34 import org.infoglue.cms.controllers.kernel.impl.simple.LanguageController;
35 import org.infoglue.cms.controllers.kernel.impl.simple.RepositoryController;
36 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeController;
37 import org.infoglue.cms.controllers.kernel.impl.simple.SiteNodeVersionController;
38 import org.infoglue.cms.entities.content.ContentVersionVO;
39 import org.infoglue.cms.entities.management.LanguageVO;
40 import org.infoglue.cms.entities.management.RepositoryVO;
41 import org.infoglue.cms.entities.structure.SiteNodeVO;
42 import org.infoglue.cms.entities.structure.SiteNodeVersion;
43 import org.infoglue.cms.entities.structure.SiteNodeVersionVO;
44 import org.infoglue.cms.util.CmsPropertyHandler;
45
46 /**
47  * This class implements the action class for the framed page in the siteNode tool.
48  *
49  * @author Mattias Bogeblad
50  */

51
52 public class ViewStructureToolToolBarAction extends InfoGlueAbstractAction
53 {
54     private final static Logger logger = Logger.getLogger(ViewStructureToolToolBarAction.class.getName());
55
56     private static final long serialVersionUID = 1L;
57
58     private String JavaDoc title = "";
59     private String JavaDoc name = "";
60     private String JavaDoc toolbarKey = "";
61     private String JavaDoc url = "";
62     private Boolean JavaDoc isBranch = new Boolean JavaDoc(false);
63         
64     //All id's that are used
65
private Integer JavaDoc repositoryId = null;
66     private Integer JavaDoc siteNodeId = null;
67     private Integer JavaDoc siteNodeVersionId = null;
68     private Integer JavaDoc lastPublishedSiteNodeVersionId = null;
69     private Integer JavaDoc metaInfoAvailableServiceBindingId = null;
70     //private Integer serviceBindingId = null;
71
private SiteNodeVersionVO siteNodeVersionVO = null;
72     
73     /**
74      * This execute method first of all gets the id of the available service-binding
75      * the meta-info-content-type has. Then we check if there is a meta-info allready bound.
76      */

77     
78     public String JavaDoc doExecute() throws Exception JavaDoc
79     {
80         try
81         {
82             if(siteNodeVersionId != null)
83             {
84                 this.siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId);
85                 
86                 /*
87                 AvailableServiceBindingVO availableServiceBindingVO = AvailableServiceBindingController.getController().getAvailableServiceBindingVOWithName("Meta information");
88                 if(availableServiceBindingVO != null)
89                     this.metaInfoAvailableServiceBindingId = availableServiceBindingVO.getAvailableServiceBindingId();
90                 
91                 List serviceBindings = SiteNodeVersionController.getServiceBindningVOList(siteNodeVersionId);
92                 Iterator serviceBindingIterator = serviceBindings.iterator();
93                 while(serviceBindingIterator.hasNext())
94                 {
95                     ServiceBindingVO serviceBindingVO = (ServiceBindingVO)serviceBindingIterator.next();
96                     if(serviceBindingVO.getAvailableServiceBindingId().intValue() == metaInfoAvailableServiceBindingId.intValue())
97                     {
98                         this.serviceBindingId = serviceBindingVO.getServiceBindingId();
99                         break;
100                     }
101                 }
102                 */

103             }
104             else if(siteNodeId != null)
105             {
106                 this.siteNodeVersionVO = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(siteNodeId);
107                 this.siteNodeVersionId = this.siteNodeVersionVO.getSiteNodeVersionId();
108                 
109                 /*
110                 AvailableServiceBindingVO availableServiceBindingVO = AvailableServiceBindingController.getController().getAvailableServiceBindingVOWithName("Meta information");
111                 if(availableServiceBindingVO != null)
112                     this.metaInfoAvailableServiceBindingId = availableServiceBindingVO.getAvailableServiceBindingId();
113                 
114                 List serviceBindings = SiteNodeVersionController.getServiceBindningVOList(siteNodeVersionVO.getId());
115                 Iterator serviceBindingIterator = serviceBindings.iterator();
116                 while(serviceBindingIterator.hasNext())
117                 {
118                     ServiceBindingVO serviceBindingVO = (ServiceBindingVO)serviceBindingIterator.next();
119                     if(serviceBindingVO.getAvailableServiceBindingId().intValue() == metaInfoAvailableServiceBindingId.intValue())
120                     {
121                         this.serviceBindingId = serviceBindingVO.getServiceBindingId();
122                         break;
123                     }
124                 }
125                 */

126             }
127         }
128         catch(Exception JavaDoc e)
129         {
130             e.printStackTrace();
131         }
132         
133         return "success";
134     }
135
136     public Integer JavaDoc getRepositoryId()
137     {
138         return this.repositoryId;
139     }
140
141     public void setRepositoryId(Integer JavaDoc repositoryId)
142     {
143         this.repositoryId = repositoryId;
144     }
145
146     public Integer JavaDoc getSiteNodeId()
147     {
148         return this.siteNodeId;
149     }
150
151     public void setSiteNodeId(Integer JavaDoc siteNodeId)
152     {
153         this.siteNodeId = siteNodeId;
154     }
155
156     public Integer JavaDoc getSiteNodeVersionId()
157     {
158         return this.siteNodeVersionId;
159     }
160     
161     public void setSiteNodeVersionId(Integer JavaDoc siteNodeVersionId)
162     {
163         this.siteNodeVersionId = siteNodeVersionId;
164     }
165
166     public String JavaDoc getTitle()
167     {
168         return this.title;
169     }
170     
171     public void setTitle(String JavaDoc title)
172     {
173         this.title = title;
174     }
175
176     public String JavaDoc getName()
177     {
178         return this.name;
179     }
180     
181     public void setName(String JavaDoc name)
182     {
183         this.name = name;
184     }
185
186     public Boolean JavaDoc getIsBranch()
187     {
188         return this.isBranch;
189     }
190     
191     public void setIsBranch(Boolean JavaDoc isBranch)
192     {
193         this.isBranch = isBranch;
194     }
195     
196     public String JavaDoc getToolbarKey()
197     {
198         return this.toolbarKey;
199     }
200
201     public void setToolbarKey(String JavaDoc toolbarKey)
202     {
203         this.toolbarKey = toolbarKey;
204     }
205
206     public void setUrl(String JavaDoc url)
207     {
208         this.url = url;
209     }
210     
211     public String JavaDoc getUrl()
212     {
213         return this.url;
214     }
215
216     /**
217      * This method checks if the site node version is read only (ie publish, published or final).
218      */

219     
220     private boolean isReadOnly()
221     {
222         boolean isReadOnly = false;
223         
224         try
225         {
226             //SiteNodeVersionVO siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(this.siteNodeVersionId);
227
if(this.siteNodeVersionVO != null && (this.siteNodeVersionVO.getStateId().intValue() == 1 || this.siteNodeVersionVO.getStateId().intValue() == 2 || this.siteNodeVersionVO.getStateId().intValue() == 3))
228             {
229                 isReadOnly = true;
230             }
231         }
232         catch(Exception JavaDoc e){}
233                 
234         return isReadOnly;
235     }
236
237     public List JavaDoc getButtons()
238     {
239         logger.info("Title:" + this.title);
240         logger.info("toolbarKey:" + this.toolbarKey);
241         try
242         {
243             if(this.toolbarKey.equalsIgnoreCase("tool.structuretool.siteNodeDetailsHeader") || this.toolbarKey.equalsIgnoreCase("tool.structuretool.siteNodeComponentsHeader"))
244             {
245                 if(this.isBranch.booleanValue())
246                     return getBranchSiteNodeButtons();
247                 else
248                     return getSiteNodeButtons();
249             }
250             else if(this.toolbarKey.equalsIgnoreCase("tool.structuretool.siteNodeVersionHeader"))
251             {
252                 return this.getSiteNodeVersionButtons();
253             }
254         }
255         catch(Exception JavaDoc e)
256         {
257             e.printStackTrace();
258             logger.warn("Exception when generating buttons:" + e.getMessage(), e);
259         }
260                             
261         return null;
262     }
263     
264     
265     /**
266      * This method checks if there are published versions available for the siteNodeVersion.
267      */

268     
269     private boolean hasPublishedVersion()
270     {
271         boolean hasPublishedVersion = false;
272         
273         try
274         {
275             SiteNodeVersion siteNodeVersion = SiteNodeVersionController.getLatestPublishedSiteNodeVersion(this.siteNodeId);
276             if(siteNodeVersion != null)
277             {
278                 hasPublishedVersion = true;
279                 lastPublishedSiteNodeVersionId = siteNodeVersion.getId();
280                 this.repositoryId = siteNodeVersion.getOwningSiteNode().getRepository().getId();
281                 this.name = siteNodeVersion.getOwningSiteNode().getName();
282                 this.siteNodeId = siteNodeVersion.getOwningSiteNode().getId();
283             }
284         }
285         catch(Exception JavaDoc e)
286         {
287             logger.warn("Exception when generating buttons:" + e.getMessage(), e);
288         }
289                 
290         return hasPublishedVersion;
291     }
292     
293     
294
295     private List JavaDoc getBranchSiteNodeButtons() throws Exception JavaDoc
296     {
297         List JavaDoc buttons = new ArrayList JavaDoc();
298         buttons.add(new ImageButton(this.getCMSBaseUrl() + "/CreateSiteNode!input.action?isBranch=true&parentSiteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.newSiteNode"), "New SiteNode"));
299         
300         ImageButton moveButton = getMoveButton();
301         moveButton.getSubButtons().add(getMoveMultipleButton());
302         buttons.add(moveButton);
303
304         //buttons.add(getMoveButton());
305
//buttons.add(getMoveMultipleButton());
306

307         if(!hasPublishedVersion())
308             buttons.add(new ImageButton(this.getCMSBaseUrl() + "/Confirm.action?header=tool.structuretool.deleteSiteNode.header&yesDestination=" + URLEncoder.encode(URLEncoder.encode("DeleteSiteNode.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&changeTypeId=4", "UTF-8"), "UTF-8") + "&noDestination=" + URLEncoder.encode(URLEncoder.encode("ViewSiteNode.action?title=SiteNode&siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId, "UTF-8"), "UTF-8") + "&message=tool.structuretool.deleteSiteNode.message", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.deleteSiteNode"), "Delete SiteNode"));
309         
310         //String serviceBindingIdString = this.serviceBindingId == null ? "" : this.serviceBindingId.toString();
311
//buttons.add(new ImageButton(true, "javascript:openPopup('ViewAndCreateContentForServiceBinding.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&siteNodeVersionId=" + this.siteNodeVersionVO.getId() + "&availableServiceBindingId=" + this.metaInfoAvailableServiceBindingId + "&serviceBindingId=" + serviceBindingIdString + "', 'PageProperties', 'width=400,height=525,resizable=no,status=yes,scrollbars=yes');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.editSiteNodeProperties"), "Edit siteNode properties"));
312

313         //SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(this.siteNodeId);
314
if(this.siteNodeVersionVO != null && this.siteNodeVersionVO.getStateId().equals(SiteNodeVersionVO.WORKING_STATE))
315             buttons.add(new ImageButton(true, "javascript:openPopup('ViewAndCreateContentForServiceBinding.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&siteNodeVersionId=" + this.siteNodeVersionVO.getId() + "', 'PageProperties', 'width=400,height=525,resizable=no,status=yes,scrollbars=yes');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.editSiteNodeProperties"), "Edit siteNode properties"));
316         else
317             buttons.add(new ImageButton(true, "javascript:openPopupWithOptionalParameter('ViewAndCreateContentForServiceBinding.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&siteNodeVersionId=" + this.siteNodeVersionVO.getId() + "', 'PageProperties', 'width=400,height=525,resizable=no,status=yes,scrollbars=yes', '" + getLocalizedString(getSession().getLocale(), "tool.structuretool.changeSiteNodeStateToWorkingQuestion") + "', 'changeStateToWorking=true');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.editSiteNodeProperties"), "Edit siteNode properties"));
318
319         buttons.add(getPreviewButtons());
320         
321         if(hasPublishedVersion())
322         {
323             ImageButton unpublishButton = new ImageButton(this.getCMSBaseUrl() + "/UnpublishSiteNodeVersion!input.action?siteNodeId=" + this.siteNodeId + "&siteNodeVersionId=" + this.siteNodeVersionId, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.unpublishVersion"), "tool.contenttool.unpublishVersion.header");
324             ImageButton unpublishAllButton = new ImageButton(this.getCMSBaseUrl() + "/UnpublishSiteNodeVersion!inputChooseSiteNodes.action?siteNodeId=" + this.siteNodeId + "&siteNodeVersionId=" + this.siteNodeVersionId, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.unpublishAllVersion"), "tool.contenttool.unpublishAllVersion.header");
325             unpublishButton.getSubButtons().add(unpublishAllButton);
326         
327             buttons.add(unpublishButton);
328         }
329         
330         ImageButton coverButton = new ImageButton(this.getCMSBaseUrl() + "/ViewSiteNode.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&stay=true", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeCover"), "SiteNode Cover");
331         coverButton.getSubButtons().add(getSimplePageComponentsButton());
332         buttons.add(coverButton);
333
334         if(!isReadOnly())
335         {
336             ImageButton pageComponentsButton = getViewPageComponentsButton();
337             pageComponentsButton.getSubButtons().add(getSimplePageComponentsButton());
338             buttons.add(pageComponentsButton);
339         }
340         
341         buttons.add(getPublishButton());
342         
343         buttons.add(getExecuteTaskButton());
344
345         if(this.siteNodeVersionVO.getIsProtected().intValue() == SiteNodeVersionVO.YES.intValue())
346             buttons.add(getAccessRightsButton());
347             
348         return buttons;
349     }
350
351     private ImageButton getPreviewButtons() throws Exception JavaDoc
352     {
353         RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(this.repositoryId);
354         
355         String JavaDoc dnsName = repositoryVO.getDnsName();
356
357         String JavaDoc workingUrl = null;
358         
359         String JavaDoc keyword = "working=";
360         int startIndex = (dnsName == null) ? -1 : dnsName.indexOf(keyword);
361         if(startIndex != -1)
362         {
363             int endIndex = dnsName.indexOf(",", startIndex);
364             if(endIndex > -1)
365                 dnsName = dnsName.substring(startIndex, endIndex);
366             else
367                 dnsName = dnsName.substring(startIndex);
368
369             workingUrl = dnsName.split("=")[1] + CmsPropertyHandler.getComponentRendererUrl() + "ViewPage.action";
370         }
371         else
372         {
373             workingUrl = CmsPropertyHandler.getPreviewDeliveryUrl();
374         }
375         
376         ImageButton imageButton = new ImageButton(true, "javascript:openPopup('" + workingUrl + "?siteNodeId=" + this.siteNodeId + "&repositoryName=" + URLEncoder.encode(repositoryVO.getName(), "UTF-8") + "&cmsUserName=" + URLEncoder.encode(this.getInfoGluePrincipal().getName(), "UTF-8") + "' , 'SiteNode', 'width=800,height=600,resizable=yes,toolbar=yes,scrollbars=yes,status=yes,location=yes,menubar=yes');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.previewSiteNode"), "Preview siteNode");
377         
378         
379         return imageButton;
380     }
381     
382     private List JavaDoc getSiteNodeButtons() throws Exception JavaDoc
383     {
384         List JavaDoc buttons = new ArrayList JavaDoc();
385         buttons.add(new ImageButton("Confirm.action?header=Delete%20siteNode&yesDestination=" + URLEncoder.encode(URLEncoder.encode("DeleteSiteNode.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&changeTypeId=4", "UTF-8"), "UTF-8") + "&noDestination=" + URLEncoder.encode(URLEncoder.encode("ViewSiteNode.action?title=SiteNode&siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId, "UTF-8"), "UTF-8") + "&message=" + URLEncoder.encode("Do you really want to delete the siteNode " + this.name + " and all its children", "UTF-8"), getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.deleteSiteNode"), "Delete SiteNode"));
386         buttons.add(getMoveButton());
387         buttons.add(getMoveMultipleButton());
388         buttons.add(getPublishButton());
389         return buttons;
390     }
391
392     private List JavaDoc getSiteNodeVersionButtons() throws Exception JavaDoc
393     {
394         List JavaDoc buttons = new ArrayList JavaDoc();
395         if(this.siteNodeVersionId != null)
396         {
397             buttons.add(new ImageButton(true, "javascript:openPopup('ViewSiteNodeVersion!preview.action?siteNodeVersionId=" + this.siteNodeVersionId + "&siteNodeId=" + this.siteNodeId + "', 'SiteNodePreview', 'width=600,height=600,resizable=yes');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.previewSiteNode"), "Preview siteNode version"));
398         }
399         
400         return buttons;
401     }
402
403     private ImageButton getMoveButton() throws Exception JavaDoc
404     {
405         return new ImageButton(true, "javascript:openPopup('ViewSiteNodeTree.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&hideLeafs=true', 'SiteNode', 'width=400,height=600,resizable=no');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.moveSiteNode"), "Move siteNode");
406     }
407     
408     private ImageButton getMoveMultipleButton()
409     {
410         return new ImageButton(true, "javascript:openPopup('MoveMultipleSiteNodes!input.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "', 'MoveMultipleSiteNodes', 'width=400,height=600,resizable=no');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.moveMultipleSiteNodes"), "tool.structuretool.moveMultipleSiteNodes.header");
411     }
412
413     private ImageButton getViewPageComponentsButton() throws Exception JavaDoc
414     {
415         try
416         {
417             boolean isMetaInfoInWorkingState = false;
418             LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(this.repositoryId);
419             Integer JavaDoc languageId = masterLanguageVO.getLanguageId();
420             
421             /*
422             if(serviceBindingId != null)
423             {
424                 List boundContents = ContentController.getBoundContents(serviceBindingId);
425                 if(boundContents.size() > 0)
426                 {
427                     ContentVO contentVO = (ContentVO)boundContents.get(0);
428                     ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageId);
429                     if(contentVersionVO.getStateId().equals(ContentVersionVO.WORKING_STATE))
430                         isMetaInfoInWorkingState = true;
431                 }
432             }
433             */

434             SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId);
435             if(siteNodeVO.getMetaInfoContentId() != null && siteNodeVO.getMetaInfoContentId().intValue() != -1)
436             {
437                 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), languageId);
438                 if(contentVersionVO.getStateId().equals(ContentVersionVO.WORKING_STATE))
439                     isMetaInfoInWorkingState = true;
440             }
441             
442             logger.info("isMetaInfoInWorkingState:" + isMetaInfoInWorkingState);
443             if(isMetaInfoInWorkingState)
444                 return new ImageButton(CmsPropertyHandler.getComponentRendererUrl() + "ViewPage!renderDecoratedPage.action?siteNodeId=" + this.siteNodeId + "&languageId=" + masterLanguageVO.getId() + "&contentId=-1" + "&cmsUserName=" + URLEncoder.encode(this.getInfoGluePrincipal().getName(), "UTF-8"), getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeComponents"), "Site Node Components");
445                 //return new ImageButton("ViewSiteNodePageComponents.action?siteNodeId=" + this.siteNodeId, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeComponents"), "Site Node Components");
446
else
447                 return new ImageButton(true, "javascript:alert('Cannot edit this page. You must first set the meta info to working. Do this by entering node properties and changing the state to working.');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeComponents"), "Site Node Components");
448         }
449         catch(Exception JavaDoc e)
450         {
451             return new ImageButton(true, "javascript:alert('Cannot edit this page. You must first assign a metainfo content. Do this by entering node properties and fill in the information requested.');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeComponents"), "Site Node Components");
452         }
453     }
454
455     private ImageButton getSimplePageComponentsButton() throws Exception JavaDoc
456     {
457         try
458         {
459             boolean isMetaInfoInWorkingState = false;
460             LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(this.repositoryId);
461             Integer JavaDoc languageId = masterLanguageVO.getLanguageId();
462
463             /*
464             if(serviceBindingId != null)
465             {
466                 List boundContents = ContentController.getBoundContents(serviceBindingId);
467                 if(boundContents.size() > 0)
468                 {
469                     ContentVO contentVO = (ContentVO)boundContents.get(0);
470                     ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageId);
471                     if(contentVersionVO.getStateId().equals(ContentVersionVO.WORKING_STATE))
472                         isMetaInfoInWorkingState = true;
473                 }
474             }
475             */

476             
477             SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId);
478             if(siteNodeVO.getMetaInfoContentId() != null && siteNodeVO.getMetaInfoContentId().intValue() != -1)
479             {
480                 ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), languageId);
481                 if(contentVersionVO.getStateId().equals(ContentVersionVO.WORKING_STATE))
482                     isMetaInfoInWorkingState = true;
483             }
484
485             logger.info("isMetaInfoInWorkingState:" + isMetaInfoInWorkingState);
486             if(isMetaInfoInWorkingState)
487                 return new ImageButton(CmsPropertyHandler.getComponentRendererUrl() + "ViewPage!renderDecoratedPage.action?siteNodeId=" + this.siteNodeId + "&languageId=" + masterLanguageVO.getId() + "&contentId=-1&showSimple=true" + "&cmsUserName=" + URLEncoder.encode(this.getInfoGluePrincipal().getName(), "UTF-8"), getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeStructure"), "Site Node Structure");
488                 //return new ImageButton("ViewSiteNodePageComponents.action?siteNodeId=" + this.siteNodeId, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeComponents"), "Site Node Components");
489
else
490                 return new ImageButton(true, "javascript:alert('Cannot edit this page. You must first set the meta info to working. Do this by entering node properties and changing the state to working.');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeStructure"), "Site Node Structure");
491         }
492         catch(Exception JavaDoc e)
493         {
494             return new ImageButton(true, "javascript:alert('Cannot edit this page. You must first assign a metainfo content. Do this by entering node properties and fill in the information requested.');", getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeStructure"), "Site Node Structure");
495         }
496     }
497
498     private ImageButton getExecuteTaskButton()
499     {
500         return new ImageButton(true, "javascript:openPopup('ViewExecuteTask.action?contentId=" + this.siteNodeId + "', 'SiteNode', 'width=400,height=600,resizable=yes,scrollbars=yes');", getLocalizedString(getSession().getLocale(), "images.global.buttons.executeTask"), "tool.common.executeTask.header");
501     }
502     
503     private ImageButton getPublishButton()
504     {
505         return new ImageButton(this.getCMSBaseUrl() + "/ViewListSiteNodeVersion.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.publishSiteNode"), "tool.structuretool.publishSiteNode.header");
506     }
507
508     private ImageButton getAccessRightsButton() throws Exception JavaDoc
509     {
510         String JavaDoc returnAddress = URLEncoder.encode(URLEncoder.encode("ViewSiteNode.action?siteNodeId=" + this.siteNodeId + "&repositoryId=" + this.repositoryId + "&stay=true", "UTF-8"), "UTF-8");
511         return new ImageButton(this.getCMSBaseUrl() + "/ViewAccessRights.action?interceptionPointCategory=SiteNodeVersion&extraParameters=" + this.siteNodeVersionId +"&colorScheme=StructureTool&returnAddress=" + returnAddress, getLocalizedString(getSession().getLocale(), "images.structuretool.buttons.siteNodeAccessRights"), "Site Node Access Rights");
512     }
513     
514     public String JavaDoc getStateDescription()
515     {
516         String JavaDoc state = "";
517         
518         if(this.siteNodeVersionVO != null)
519         {
520             if(this.siteNodeVersionVO.getStateId().equals(SiteNodeVersionVO.WORKING_STATE))
521                 state = "<span style=\"color:#333333; font-weight: strong;\">(" + getLocalizedString(getSession().getLocale(), "tool.contenttool.state.working") + ")</span>";
522             else if(this.siteNodeVersionVO.getStateId().equals(SiteNodeVersionVO.FINAL_STATE))
523                 state = "<span style=\"color:#AAAAAA; font-weight: strong;\">(" + getLocalizedString(getSession().getLocale(), "tool.contenttool.state.final") + ")</span>";
524             else if(this.siteNodeVersionVO.getStateId().equals(SiteNodeVersionVO.PUBLISH_STATE))
525                 state = "<span style=\"color:#888888; font-weight: normal;\">(" + getLocalizedString(getSession().getLocale(), "tool.contenttool.state.publish") + ")</span>";
526             else if(this.siteNodeVersionVO.getStateId().equals(SiteNodeVersionVO.PUBLISHED_STATE))
527                 state = "<span style=\"color:#666666; font-weight: normal;\">(" + getLocalizedString(getSession().getLocale(), "tool.contenttool.state.published") + ")</span>";
528         }
529         
530         return state;
531     }
532 /*
533     public Integer getServiceBindingId()
534     {
535         return serviceBindingId;
536     }
537
538     public void setServiceBindingId(Integer integer)
539     {
540         serviceBindingId = integer;
541     }
542 */

543 }
544
Popular Tags