KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > deliver > controllers > kernel > impl > simple > BasicTemplateController


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.deliver.controllers.kernel.impl.simple;
25
26 import java.awt.Color JavaDoc;
27 import java.awt.Font JavaDoc;
28 import java.io.File JavaDoc;
29 import java.io.PrintWriter JavaDoc;
30 import java.io.StringWriter JavaDoc;
31 import java.io.UnsupportedEncodingException JavaDoc;
32 import java.net.URLEncoder JavaDoc;
33 import java.security.Principal JavaDoc;
34 import java.text.NumberFormat JavaDoc;
35 import java.util.ArrayList JavaDoc;
36 import java.util.Collection JavaDoc;
37 import java.util.Collections JavaDoc;
38 import java.util.Enumeration JavaDoc;
39 import java.util.HashMap JavaDoc;
40 import java.util.Iterator JavaDoc;
41 import java.util.List JavaDoc;
42 import java.util.Locale JavaDoc;
43 import java.util.Map JavaDoc;
44 import java.util.Set JavaDoc;
45 import java.util.Vector JavaDoc;
46
47 import javax.servlet.http.Cookie JavaDoc;
48 import javax.servlet.http.HttpServletRequest JavaDoc;
49
50 import org.apache.log4j.Logger;
51 import org.apache.oro.text.regex.MalformedPatternException;
52 import org.apache.oro.text.regex.MatchResult;
53 import org.apache.oro.text.regex.Pattern;
54 import org.apache.oro.text.regex.PatternCompiler;
55 import org.apache.oro.text.regex.PatternMatcher;
56 import org.apache.oro.text.regex.PatternMatcherInput;
57 import org.apache.oro.text.regex.Perl5Compiler;
58 import org.apache.oro.text.regex.Perl5Matcher;
59 import org.dom4j.Document;
60 import org.dom4j.Element;
61 import org.exolab.castor.jdo.Database;
62 import org.infoglue.cms.applications.common.VisualFormatter;
63 import org.infoglue.cms.controllers.kernel.impl.simple.AccessRightController;
64 import org.infoglue.cms.controllers.kernel.impl.simple.CastorDatabaseService;
65 import org.infoglue.cms.controllers.kernel.impl.simple.CategoryConditions;
66 import org.infoglue.cms.controllers.kernel.impl.simple.ContentTypeDefinitionController;
67 import org.infoglue.cms.controllers.kernel.impl.simple.ExtendedSearchController;
68 import org.infoglue.cms.controllers.kernel.impl.simple.GroupControllerProxy;
69 import org.infoglue.cms.controllers.kernel.impl.simple.GroupPropertiesController;
70 import org.infoglue.cms.controllers.kernel.impl.simple.InfoGluePrincipalControllerProxy;
71 import org.infoglue.cms.controllers.kernel.impl.simple.RoleControllerProxy;
72 import org.infoglue.cms.controllers.kernel.impl.simple.RolePropertiesController;
73 import org.infoglue.cms.controllers.kernel.impl.simple.UserControllerProxy;
74 import org.infoglue.cms.controllers.kernel.impl.simple.WorkflowController;
75 import org.infoglue.cms.entities.content.Content;
76 import org.infoglue.cms.entities.content.ContentVO;
77 import org.infoglue.cms.entities.content.ContentVersionVO;
78 import org.infoglue.cms.entities.management.ContentTypeAttribute;
79 import org.infoglue.cms.entities.management.ContentTypeDefinitionVO;
80 import org.infoglue.cms.entities.management.LanguageVO;
81 import org.infoglue.cms.entities.structure.SiteNode;
82 import org.infoglue.cms.entities.structure.SiteNodeVO;
83 import org.infoglue.cms.entities.structure.SiteNodeVersionVO;
84 import org.infoglue.cms.exception.SystemException;
85 import org.infoglue.cms.security.AuthenticationModule;
86 import org.infoglue.cms.security.InfoGlueGroup;
87 import org.infoglue.cms.security.InfoGluePrincipal;
88 import org.infoglue.cms.security.InfoGlueRole;
89 import org.infoglue.cms.util.CmsPropertyHandler;
90 import org.infoglue.cms.util.DesEncryptionHelper;
91 import org.infoglue.cms.util.dom.DOMBuilder;
92 import org.infoglue.cms.util.sorters.SiteNodeComparator;
93 import org.infoglue.deliver.applications.databeans.ComponentProperty;
94 import org.infoglue.deliver.applications.databeans.DatabaseWrapper;
95 import org.infoglue.deliver.applications.databeans.DeliveryContext;
96 import org.infoglue.deliver.applications.databeans.WebPage;
97 import org.infoglue.deliver.applications.filters.FilterConstants;
98 import org.infoglue.deliver.controllers.kernel.URLComposer;
99 import org.infoglue.deliver.invokers.DecoratedComponentBasedHTMLPageInvoker;
100 import org.infoglue.deliver.util.BrowserBean;
101 import org.infoglue.deliver.util.CacheController;
102 import org.infoglue.deliver.util.HttpHelper;
103 import org.infoglue.deliver.util.MathHelper;
104 import org.infoglue.deliver.util.ObjectConverter;
105 import org.infoglue.deliver.util.VelocityTemplateProcessor;
106 import org.infoglue.deliver.util.charts.ChartHelper;
107 import org.infoglue.deliver.util.forms.FormHelper;
108 import org.infoglue.deliver.util.graphics.AdvancedImageRenderer;
109 import org.infoglue.deliver.util.graphics.ColorHelper;
110 import org.infoglue.deliver.util.graphics.FOPHelper;
111 import org.infoglue.deliver.util.graphics.FontHelper;
112 import org.infoglue.deliver.util.graphics.ImageRenderer;
113 import org.infoglue.deliver.util.rss.RssHelper;
114 import org.infoglue.deliver.util.webservices.InfoGlueWebServices;
115 import org.infoglue.deliver.util.webservices.WebServiceHelper;
116
117 /**
118  * This is the most basic template controller supplying the templates using it with
119  * methods to fetch contents, structure and other suff needed for a site. Mostly this class just acts as a
120  * delegator to other more specialized classes.
121  */

122
123 public class BasicTemplateController implements TemplateController
124 {
125     private final static Logger logger = Logger.getLogger(BasicTemplateController.class.getName());
126
127     private URLComposer urlComposer = null;
128     
129     public static final String JavaDoc META_INFO_BINDING_NAME = "Meta information";
130     public static final String JavaDoc TEMPLATE_ATTRIBUTE_NAME = "Template";
131     public static final String JavaDoc TITLE_ATTRIBUTE_NAME = "Title";
132     public static final String JavaDoc NAV_TITLE_ATTRIBUTE_NAME = "NavigationTitle";
133     /*
134     protected static final String DISABLE_PAGE_CACHE_ATTRIBUTE_NAME = "DisablePageCache";
135     protected static final String PAGE_CONTENT_TYPE_ATTRIBUTE_NAME = "ContentType";
136     protected static final String ENABLE_PAGE_PROTECTION_ATTRIBUTE_NAME = "ProtectPage";
137     protected static final String DISABLE_EDIT_ON_SIGHT_ATTRIBUTE_NAME = "DisableEditOnSight";
138     */

139     protected static final boolean USE_LANGUAGE_FALLBACK = true;
140     protected static final boolean DO_NOT_USE_LANGUAGE_FALLBACK = false;
141     protected static final boolean USE_INHERITANCE = true;
142     protected static final boolean DO_NOT_USE_INHERITANCE = false;
143
144     protected Integer JavaDoc siteNodeId = null;
145     protected Integer JavaDoc languageId = null;
146     protected Integer JavaDoc contentId = null;
147     
148     protected HttpServletRequest JavaDoc request = null;
149     protected DeliveryContext deliveryContext = null;
150     
151     protected BrowserBean browserBean = null;
152     
153     protected NodeDeliveryController nodeDeliveryController = null;
154     protected ContentDeliveryController contentDeliveryController = null;
155     protected IntegrationDeliveryController integrationDeliveryController = null;
156     
157     protected ComponentLogic componentLogic = null;
158
159     protected InfoGluePrincipal infoGluePrincipal = null;
160     
161     // For adding objects to be used in subsequent parsing
162
// like getParsedContentAttribute, include, etc
163
protected Map JavaDoc templateLogicContext = new HashMap JavaDoc();
164     protected boolean persistedContext = false;
165
166     protected DatabaseWrapper databaseWrapper = null;
167     
168     private boolean threatFoldersAsContents = false;
169     
170     /**
171      * The constructor for the templateController. It should be used to initialize the
172      * templateController for efficient use.
173      */

174     
175     public BasicTemplateController(DatabaseWrapper databaseWrapper, InfoGluePrincipal infoGluePrincipal)
176     {
177         this.databaseWrapper = databaseWrapper;
178         this.infoGluePrincipal = infoGluePrincipal;
179         this.urlComposer = URLComposer.getURLComposer();
180     }
181
182     
183     /**
184      * Gets the transaction the controller should work within. This is to limit the number of connections we use.
185      */

186     
187     public Database getDatabase() throws SystemException
188     {
189         if(this.databaseWrapper.getDatabase() == null || this.databaseWrapper.getDatabase().isClosed() || !this.databaseWrapper.getDatabase().isActive())
190         {
191             beginTransaction();
192         }
193
194         return this.databaseWrapper.getDatabase();
195     }
196
197     public DatabaseWrapper getDatabaseWrapper()
198     {
199         return databaseWrapper;
200     }
201
202     /**
203      * Commits and reopens a database object so we don't have to long transaction.
204      */

205     
206     public void commitDatabase() throws SystemException
207     {
208         logger.debug("Committing database in the middle of the run....");
209         try
210         {
211             this.databaseWrapper.getDatabase().commit();
212             this.databaseWrapper.getDatabase().close();
213             logger.info("Closed transaction...");
214             this.databaseWrapper.setDatabase(CastorDatabaseService.getDatabase());
215             //this.databaseWrapper = new DatabaseWrapper(CastorDatabaseService.getDatabase());
216
beginTransaction();
217             logger.info("Begun a new transaction...");
218         }
219         catch(Exception JavaDoc e)
220         {
221             e.printStackTrace();
222             throw new SystemException("An error occurred when we tried to commit an transaction. Reason:" + e.getMessage(), e);
223         }
224     }
225
226     /**
227      * Commit transactions so far so a different call can be made which otherwise gets a deadlock.
228      */

229
230     public void closeTransaction() throws SystemException
231     {
232         try
233         {
234             this.databaseWrapper.getDatabase().commit();
235             //this.db.close();
236
logger.info("Closed transaction...");
237         }
238         catch(Exception JavaDoc e)
239         {
240             e.printStackTrace();
241             throw new SystemException("An error occurred when we tried to commit an transaction. Reason:" + e.getMessage(), e);
242         }
243     }
244
245     /**
246      * Starts a new transaction so a different call can be made.
247      */

248     
249     private void beginTransaction() throws SystemException
250     {
251         try
252         {
253             this.databaseWrapper.getDatabase().begin();
254             logger.info("Started new transaction...");
255         }
256         catch(Exception JavaDoc e)
257         {
258             e.printStackTrace();
259             throw new SystemException("An error occurred when we tried to begin an transaction. Reason:" + e.getMessage(), e);
260         }
261     }
262  
263     
264     
265     
266     /**
267      * Add objects to be used in subsequent parsing
268      * like getParsedContentAttribute, include, etc
269      */

270     public void addToContext(String JavaDoc name, Object JavaDoc object)
271     {
272         templateLogicContext.put(name, object);
273     }
274     
275     /**
276      * Add objects to be used in subsequent parsing
277      * like getParsedContentAttribute, include, etc
278      * this method adds all objects in the map to
279      * the templateLogicContext, the method is protected
280      * and is used by getTemplateController to pass on
281      * the current context to the new controller if
282      * persistedContext is true.
283      */

284     protected void addToContext(Map JavaDoc context)
285     {
286         templateLogicContext.putAll(context);
287     }
288     
289     /**
290      * Gets objects from the context
291      */

292     public Object JavaDoc getFromContext(String JavaDoc name)
293     {
294         return templateLogicContext.get(name);
295     }
296     
297     /**
298      * Setter for the template to get all the parameters from the user.
299      */

300     
301     public void setStandardRequestParameters(Integer JavaDoc siteNodeId, Integer JavaDoc languageId, Integer JavaDoc contentId)
302     {
303         this.siteNodeId = siteNodeId;
304         this.languageId = languageId;
305         this.contentId = contentId;
306     }
307
308     /**
309      * Setter for the template to get all the parameters from the user.
310      */

311
312     public void setHttpRequest(HttpServletRequest JavaDoc request)
313     {
314         this.request = request;
315     }
316     
317
318     /**
319      * Setter for the bean which contains information about the users browser.
320      */

321      
322     public void setBrowserBean(BrowserBean browserBean)
323     {
324         this.browserBean = browserBean;
325     }
326
327     /**
328      * Getter for the template attribute name.
329      */

330     
331     public String JavaDoc getTemplateAttributeName()
332     {
333         return TEMPLATE_ATTRIBUTE_NAME;
334     }
335     
336     /**
337      * Getter for the siteNodeId
338      */

339     
340     public Integer JavaDoc getSiteNodeId()
341     {
342         return this.siteNodeId;
343     }
344     
345     /**
346      * Getter for the languageId
347      */

348     
349     public Integer JavaDoc getLanguageId()
350     {
351         return this.languageId;
352     }
353
354     
355
356     /**
357      * Getter for the contentId
358      */

359     
360     public Integer JavaDoc getContentId()
361     {
362         return this.contentId;
363     }
364     
365     /**
366      * This method gets a component logic helper object.
367      */

368     
369     public ComponentLogic getComponentLogic()
370     {
371         return this.componentLogic;
372     }
373     
374     /**
375      * This method gets a component logic helper object.
376      */

377     
378     public void setComponentLogic(ComponentLogic componentLogic)
379     {
380         this.componentLogic = componentLogic;
381     }
382
383
384     /**
385      * This method gets the formatter object that helps with formatting of data.
386      */

387     
388     public VisualFormatter getVisualFormatter()
389     {
390         return new VisualFormatter();
391     }
392
393     /**
394      * This method gets the color utility.
395      */

396     
397     public ColorHelper getColorHelper()
398     {
399         return new ColorHelper();
400     }
401
402     /**
403      * This method gets the form utility.
404      */

405     
406     public FormHelper getFormHelper()
407     {
408         return new FormHelper();
409     }
410     
411     /**
412      * This method gets the color utility.
413      */

414     
415     public FontHelper getFontHelper()
416     {
417         return new FontHelper();
418     }
419
420     /**
421      * This method gets the math utility.
422      */

423     
424     public MathHelper getMathHelper()
425     {
426         return new MathHelper();
427     }
428     
429     /**
430      * This method gets the math utility.
431      */

432     
433     public HttpHelper getHTTPHelper()
434     {
435         return new HttpHelper();
436     }
437     
438     /**
439      * This method gets the math utility.
440      */

441     
442     public ChartHelper getChartHelper()
443     {
444         return new ChartHelper(this);
445     }
446     
447     /**
448      * This method gets the webservice utility.
449      */

450     
451     public WebServiceHelper getWebServiceHelper()
452     {
453         return new WebServiceHelper();
454     }
455     
456     /**
457      * This method gets the webservice utility which has special api:s to call the infoglue system.
458      */

459     
460     public InfoGlueWebServices getInfoGlueWebServiceHelper()
461     {
462         return new InfoGlueWebServices();
463     }
464     
465     /**
466      * This method gets the NumberFormat instance with the proper locale.
467      */

468     public NumberFormat JavaDoc getNumberFormatHelper() throws SystemException
469     {
470         return NumberFormat.getInstance (
471                 LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(getDatabase(), this.languageId)
472             );
473     }
474
475     /**
476      * This method gets the DesEncryptionHelper.
477      */

478     
479     public DesEncryptionHelper getDesEncryptionHelper()
480     {
481         return new DesEncryptionHelper();
482     }
483
484     /**
485      * This method gets the rss utility.
486      */

487     
488     public RssHelper getRssHelper()
489     {
490         return new RssHelper();
491     }
492
493     /**
494      * This method gets the object converter utility.
495      */

496     
497     public ObjectConverter getObjectConverter()
498     {
499         return new ObjectConverter();
500     }
501
502     
503     /**
504      * This method delivers a map with all unparsed content attributes
505      */

506     public Map JavaDoc getContentAttributes(Integer JavaDoc contentId)
507     {
508         Map JavaDoc result = new HashMap JavaDoc();
509         ContentTypeDefinitionVO typeDefinitionVO = getContentTypeDefinitionVO(contentId);
510         List JavaDoc contentAttributes = getContentAttributes(typeDefinitionVO.getSchemaValue());
511         
512         for(Iterator JavaDoc i=contentAttributes.iterator();i.hasNext();)
513         {
514             ContentTypeAttribute contentTypeAttribute = (ContentTypeAttribute) i.next();
515             String JavaDoc name = contentTypeAttribute.getName();
516             result.put(name, getContentAttribute(contentId, name));
517         }
518         return result;
519     }
520     
521     /**
522      * This method delivers a map with all parsed content attributes
523      */

524     public Map JavaDoc getParsedContentAttributes(Integer JavaDoc contentId)
525     {
526         Map JavaDoc result = new HashMap JavaDoc();
527         ContentTypeDefinitionVO typeDefinitionVO = getContentTypeDefinitionVO(contentId);
528         List JavaDoc contentAttributes = getContentAttributes(typeDefinitionVO.getSchemaValue());
529         
530         for(Iterator JavaDoc i=contentAttributes.iterator();i.hasNext();)
531         {
532             ContentTypeAttribute contentTypeAttribute = (ContentTypeAttribute) i.next();
533             String JavaDoc name = contentTypeAttribute.getName();
534             result.put(name, getParsedContentAttribute(contentId, name));
535         }
536         return result;
537     }
538     
539     
540     /**
541      * Getter for the current content
542      */

543     
544     public ContentVO getContent()
545     {
546         ContentVO content = null;
547
548         try
549         {
550             content = ContentDeliveryController.getContentDeliveryController().getContentVO(getDatabase(), this.contentId, this.deliveryContext);
551         }
552         catch(Exception JavaDoc e)
553         {
554             logger.warn("An error occurred trying to get the current content:" + e.getMessage(), e);
555         }
556
557         return content;
558     }
559     
560     /**
561      * Getter for the current content
562      */

563     
564     public ContentVO getContent(Integer JavaDoc contentId)
565     {
566         ContentVO content = null;
567
568         try
569         {
570             content = ContentDeliveryController.getContentDeliveryController().getContentVO(getDatabase(), contentId, this.deliveryContext);
571         }
572         catch(Exception JavaDoc e)
573         {
574             logger.warn("An error occurred trying to get the content with id " + contentId + ":" + e.getMessage(), e);
575         }
576
577         return content;
578     }
579
580     /**
581      * Getter for the most recent contentVersion on a content
582      */

583     
584     public ContentVersionVO getContentVersion(Integer JavaDoc contentId)
585     {
586         ContentVersionVO contentVersionVO = null;
587
588         try
589         {
590             contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, this.languageId, true, this.deliveryContext, this.infoGluePrincipal);
591         }
592         catch(Exception JavaDoc e)
593         {
594             logger.warn("An error occurred trying to get the contentVersion with contentId " + contentId + ":" + e.getMessage(), e);
595         }
596
597         return contentVersionVO;
598     }
599
600     /**
601      * Getter for the most recent contentVersion on a content
602      */

603     
604     public ContentVersionVO getContentVersion(Integer JavaDoc contentId, Integer JavaDoc languageId, boolean useLanguageFallback)
605     {
606         ContentVersionVO contentVersionVO = null;
607
608         try
609         {
610             contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, languageId, useLanguageFallback, this.deliveryContext, this.infoGluePrincipal);
611         }
612         catch(Exception JavaDoc e)
613         {
614             logger.warn("An error occurred trying to get the contentVersion with contentId " + contentId + ":" + e.getMessage(), e);
615         }
616
617         return contentVersionVO;
618     }
619     
620     /**
621      * Returns the logged in user - that is the one currently looking at the page
622      */

623     public InfoGluePrincipal getPrincipal()
624     {
625         return this.infoGluePrincipal;
626     }
627
628     /**
629      * Returns a list of InfoGlueRoles
630      */

631     public List JavaDoc getAllRoles() throws Exception JavaDoc
632     {
633         return RoleControllerProxy.getController(this.getDatabase()).getAllRoles();
634     }
635
636     /**
637      * Returns a list of InfoGlueGroups
638      */

639     public List JavaDoc getAllGroups() throws Exception JavaDoc
640     {
641         return GroupControllerProxy.getController(this.getDatabase()).getAllGroups();
642     }
643
644     /**
645      * This method returns the InfoGlue Principal requested
646      *
647      * @param userName
648      */

649     
650     public InfoGluePrincipal getPrincipal(String JavaDoc userName)
651     {
652         if(userName == null || userName.equals(""))
653             return null;
654         
655         InfoGluePrincipal infoGluePrincipal = null;
656         
657         try
658         {
659             infoGluePrincipal = UserControllerProxy.getController(getDatabase()).getUser(userName);
660         }
661         catch(Exception JavaDoc e)
662         {
663             logger.warn("An error occurred when getting principal:" + e.getMessage(), e);
664         }
665         
666         return infoGluePrincipal;
667     }
668     
669     
670     /**
671      * Getting a property for the current Principal - used for personalisation.
672      * This method starts with getting the property on the user and if it does not exist we check out the
673      * group-properties as well.
674      */

675     
676     public String JavaDoc getPrincipalPropertyValue(String JavaDoc propertyName)
677     {
678         return getPrincipalPropertyValue(propertyName, true);
679     }
680
681     /**
682      * Getting a property for the current Principal - used for personalisation.
683      * This method starts with getting the property on the user and if it does not exist we check out the
684      * group-properties as well.
685      */

686     
687     public Map JavaDoc getPrincipalPropertyHashValues(String JavaDoc propertyName)
688     {
689         return getPrincipalPropertyHashValues(propertyName, true);
690     }
691
692     /**
693      * Getting a property for the current Principal - used for personalisation.
694      * This method starts with getting the property on the user and if it does not exist we check out the
695      * group-properties as well.
696      */

697     
698     public String JavaDoc getPrincipalPropertyValue(InfoGluePrincipal infoGluePrincipal, String JavaDoc propertyName)
699     {
700         return getPrincipalPropertyValue(infoGluePrincipal, propertyName, true);
701     }
702
703     /**
704      * Getting a property for a Principal - used for personalisation.
705      * This method starts with getting the property on the user and if it does not exist we check out the
706      * group-properties as well.
707      */

708     
709     public Map JavaDoc getPrincipalPropertyHashValues(InfoGluePrincipal infoGluePrincipal, String JavaDoc propertyName)
710     {
711         return getPrincipalPropertyHashValues(infoGluePrincipal, propertyName, true);
712     }
713
714     
715     /**
716      * Getting a property for a Principal - used for personalisation.
717      * This method starts with getting the property on the user and if it does not exist we check out the
718      * group-properties as well.
719      */

720     
721     public String JavaDoc getPrincipalPropertyValue(InfoGluePrincipal infoGluePrincipal, String JavaDoc propertyName, boolean escapeSpecialCharacters)
722     {
723         String JavaDoc value = "";
724         
725         try
726         {
727             //value = ExtranetController.getController().getPrincipalPropertyValue(getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
728
value = getPrincipalPropertyValue(infoGluePrincipal, propertyName, escapeSpecialCharacters, false);
729         }
730         catch(Exception JavaDoc e)
731         {
732             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
733         }
734         
735         return value;
736     }
737
738     /**
739      * Getting a property for a Principal - used for personalisation.
740      * This method starts with getting the property on the user and if it does not exist we check out the
741      * group-properties as well.
742      */

743     
744     public String JavaDoc getPrincipalPropertyValue(InfoGluePrincipal infoGluePrincipal, String JavaDoc propertyName, boolean escapeSpecialCharacters, boolean findLargestValue)
745     {
746         String JavaDoc value = "";
747         
748         try
749         {
750             //value = ExtranetController.getController().getPrincipalPropertyValue(getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
751
value = InfoGluePrincipalControllerProxy.getController().getPrincipalPropertyValue(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters, findLargestValue);
752         }
753         catch(Exception JavaDoc e)
754         {
755             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
756         }
757         
758         return value;
759     }
760
761     
762     /**
763      * Getting a property for the current Principal - used for personalisation.
764      * This method starts with getting the property on the user and if it does not exist we check out the
765      * group-properties as well.
766      */

767     
768     public String JavaDoc getPrincipalPropertyValue(String JavaDoc propertyName, boolean escapeSpecialCharacters)
769     {
770         String JavaDoc value = "";
771         
772         try
773         {
774             InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
775             //value = ExtranetController.getController().getPrincipalPropertyValue(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
776
value = getPrincipalPropertyValue(propertyName, escapeSpecialCharacters, false);
777         }
778         catch(Exception JavaDoc e)
779         {
780             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
781         }
782         
783         return value;
784     }
785     
786
787     /**
788      * Getting a property for the current Principal - used for personalisation.
789      * This method starts with getting the property on the user and if it does not exist we check out the
790      * group-properties as well.
791      */

792     
793     public String JavaDoc getPrincipalPropertyValue(String JavaDoc propertyName, boolean escapeSpecialCharacters, boolean findLargestValue)
794     {
795         String JavaDoc value = "";
796         
797         try
798         {
799             InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
800             //value = ExtranetController.getController().getPrincipalPropertyValue(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
801
value = InfoGluePrincipalControllerProxy.getController().getPrincipalPropertyValue(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters, findLargestValue);
802         }
803         catch(Exception JavaDoc e)
804         {
805             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
806         }
807         
808         return value;
809     }
810
811     
812     /**
813      * Getting a property for a Principal - used for personalisation.
814      * This method starts with getting the property on the user and if it does not exist we check out the
815      * group-properties as well.
816      */

817     
818     public Map JavaDoc getPrincipalPropertyHashValues(InfoGluePrincipal infoGluePrincipal, String JavaDoc propertyName, boolean escapeSpecialCharacters)
819     {
820         Map JavaDoc value = new HashMap JavaDoc();
821         
822         try
823         {
824             //value = ExtranetController.getController().getPrincipalPropertyHashValues(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
825
value = InfoGluePrincipalControllerProxy.getController().getPrincipalPropertyHashValues(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
826         }
827         catch(Exception JavaDoc e)
828         {
829             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
830         }
831         
832         return value;
833     }
834     
835     
836     /**
837      * Getting a property for the current Principal - used for personalisation.
838      * This method starts with getting the property on the user and if it does not exist we check out the
839      * group-properties as well.
840      */

841     
842     public Map JavaDoc getPrincipalPropertyHashValues(String JavaDoc propertyName, boolean escapeSpecialCharacters)
843     {
844         Map JavaDoc value = new HashMap JavaDoc();
845         
846         try
847         {
848             InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
849             //value = ExtranetController.getController().getPrincipalPropertyHashValues(this.getDatabase(), infoGluePrincipal, propertyName, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, escapeSpecialCharacters);
850
value = getPrincipalPropertyHashValues(this.infoGluePrincipal, propertyName, escapeSpecialCharacters);
851         }
852         catch(Exception JavaDoc e)
853         {
854             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
855         }
856         
857         return value;
858     }
859
860     
861     public boolean getHasPrincipalGroup(InfoGluePrincipal infoGluePrincipal, String JavaDoc groupName)
862     {
863         boolean isValid = false;
864         Iterator JavaDoc groupsIterator = infoGluePrincipal.getGroups().iterator();
865         while(groupsIterator.hasNext())
866         {
867             InfoGlueGroup infoglueGroup = (InfoGlueGroup)groupsIterator.next();
868             if(infoglueGroup.getName().equalsIgnoreCase(groupName))
869             {
870                 isValid = true;
871             }
872         }
873         
874         return isValid;
875     }
876     
877     /**
878      * Getting all related contents for the current Principals group - used for personalisation.
879      */

880     
881     public List JavaDoc getPrincipalGroupRelatedContents(String JavaDoc groupName, String JavaDoc propertyName)
882     {
883         return getPrincipalGroupRelatedContents(this.infoGluePrincipal, groupName, propertyName);
884     }
885     
886     /**
887      * Getting all related contents for the current Principals group - used for personalisation.
888      */

889     
890     public List JavaDoc getPrincipalGroupRelatedContents(InfoGluePrincipal infoGluePrincipal, String JavaDoc groupName, String JavaDoc propertyName)
891     {
892         List JavaDoc contents = new ArrayList JavaDoc();
893         
894         try
895         {
896             if(getHasPrincipalGroup(infoGluePrincipal, groupName))
897                 contents = GroupPropertiesController.getController().getRelatedContents(groupName, this.languageId, propertyName);
898         }
899         catch(Exception JavaDoc e)
900         {
901             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
902         }
903         
904         return contents;
905     }
906
907     /**
908      * Getting related pages for a Principals group - used for personalisation.
909      */

910     
911     public List JavaDoc getPrincipalGroupRelatedPages(String JavaDoc groupName, String JavaDoc propertyName)
912     {
913         return getPrincipalGroupRelatedPages(this.infoGluePrincipal, groupName, propertyName);
914     }
915
916     /**
917      * Getting related pages for a Principals group - used for personalisation.
918      */

919     
920     public List JavaDoc getPrincipalGroupRelatedPages(String JavaDoc groupName, String JavaDoc propertyName, boolean escapeHTML)
921     {
922         return getPrincipalGroupRelatedPages(this.infoGluePrincipal, groupName, propertyName, escapeHTML);
923     }
924
925
926     /**
927      * Getting related pages for a Principals group - used for personalisation.
928      */

929     
930     public List JavaDoc getPrincipalGroupRelatedPages(InfoGluePrincipal infoGluePrincipal, String JavaDoc groupName, String JavaDoc propertyName)
931     {
932         return getPrincipalGroupRelatedPages(this.infoGluePrincipal, groupName, propertyName, false);
933     }
934     
935     /**
936      * Getting related pages for a Principals group - used for personalisation.
937      */

938     
939     public List JavaDoc getPrincipalGroupRelatedPages(InfoGluePrincipal infoGluePrincipal, String JavaDoc groupName, String JavaDoc propertyName, boolean escapeHTML)
940     {
941         List JavaDoc pages = new ArrayList JavaDoc();
942         
943         try
944         {
945             if(getHasPrincipalGroup(infoGluePrincipal, groupName))
946             {
947                 List JavaDoc siteNodeVOList = GroupPropertiesController.getController().getRelatedSiteNodes(groupName, this.languageId, propertyName);
948                 
949                 Iterator JavaDoc i = siteNodeVOList.iterator();
950                 while(i.hasNext())
951                 {
952                     SiteNodeVO siteNodeVO = (SiteNodeVO)i.next();
953                     try
954                     {
955                         WebPage webPage = new WebPage();
956                         webPage.setSiteNodeId(siteNodeVO.getSiteNodeId());
957                         webPage.setLanguageId(this.languageId);
958                         webPage.setContentId(null);
959                         webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML));
960                         webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext));
961                         webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext));
962                         pages.add(webPage);
963                     }
964                     catch(Exception JavaDoc e)
965                     {
966                         logger.info("An error occurred when looking up one of the related pages:" + e.getMessage(), e);
967                     }
968                 }
969             }
970         }
971         catch(Exception JavaDoc e)
972         {
973             logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
974         }
975         
976         return pages;
977     }
978
979     /**
980      * Getting all categories assigned to a property for a Role - used for personalisation.
981      */

982     
983     public List JavaDoc getPrincipalGroupCategories(String JavaDoc groupName, String JavaDoc propertyName)
984     {
985         return getPrincipalGroupCategories(this.infoGluePrincipal, groupName, propertyName);
986     }
987     
988     /**
989      * Getting all categories assigned to a property for a Role - used for personalisation.
990      */

991     
992     public List JavaDoc getPrincipalGroupCategories(InfoGluePrincipal infoGluePrincipal, String JavaDoc groupName, String JavaDoc propertyName)
993     {
994         List JavaDoc categories = new ArrayList JavaDoc();
995         
996         try
997         {
998             if(getHasPrincipalGroup(infoGluePrincipal, groupName))
999                 categories = GroupPropertiesController.getController().getRelatedCategories(groupName, this.languageId, propertyName);
1000        }
1001        catch(Exception JavaDoc e)
1002        {
1003            logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
1004        }
1005        
1006        return categories;
1007    }
1008
1009    
1010    public boolean getHasPrincipalRole(InfoGluePrincipal infoGluePrincipal, String JavaDoc roleName)
1011    {
1012        boolean isValid = false;
1013        Iterator JavaDoc groupsIterator = infoGluePrincipal.getRoles().iterator();
1014        while(groupsIterator.hasNext())
1015        {
1016            InfoGlueRole infoglueRole = (InfoGlueRole)groupsIterator.next();
1017            if(infoglueRole.getName().equalsIgnoreCase(roleName))
1018            {
1019                isValid = true;
1020            }
1021        }
1022        
1023        return isValid;
1024    }
1025    
1026    /**
1027     * Getting all related contents for the current Principals role - used for personalisation.
1028     */

1029    
1030    public List JavaDoc getPrincipalRoleRelatedContents(String JavaDoc roleName, String JavaDoc propertyName)
1031    {
1032        return getPrincipalRoleRelatedContents(this.infoGluePrincipal, roleName, propertyName);
1033    }
1034    
1035    /**
1036     * Getting all related contents for the current Principals role - used for personalisation.
1037     */

1038    
1039    public List JavaDoc getPrincipalRoleRelatedContents(InfoGluePrincipal infoGluePrincipal, String JavaDoc roleName, String JavaDoc propertyName)
1040    {
1041        List JavaDoc contents = new ArrayList JavaDoc();
1042        
1043        try
1044        {
1045            if(getHasPrincipalRole(infoGluePrincipal, roleName))
1046                contents = RolePropertiesController.getController().getRelatedContents(roleName, this.languageId, propertyName);
1047        }
1048        catch(Exception JavaDoc e)
1049        {
1050            logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
1051        }
1052        
1053        return contents;
1054    }
1055
1056    /**
1057     * Getting related pages for a Principals role - used for personalisation.
1058     */

1059    
1060    public List JavaDoc getPrincipalRoleRelatedPages(String JavaDoc roleName, String JavaDoc propertyName)
1061    {
1062        return getPrincipalRoleRelatedPages(this.infoGluePrincipal, roleName, propertyName);
1063    }
1064
1065    /**
1066     * Getting related pages for a Principals role - used for personalisation.
1067     */

1068    
1069    public List JavaDoc getPrincipalRoleRelatedPages(String JavaDoc roleName, String JavaDoc propertyName, boolean escapeHTML)
1070    {
1071        return getPrincipalRoleRelatedPages(this.infoGluePrincipal, roleName, propertyName, escapeHTML);
1072    }
1073
1074    /**
1075     * Getting related pages for a Principals role - used for personalisation.
1076     */

1077    
1078    public List JavaDoc getPrincipalRoleRelatedPages(InfoGluePrincipal infoGluePrincipal, String JavaDoc roleName, String JavaDoc propertyName)
1079    {
1080        return getPrincipalRoleRelatedPages(this.infoGluePrincipal, roleName, propertyName, false);
1081    }
1082
1083    /**
1084     * Getting related pages for a Principals role - used for personalisation.
1085     */

1086    
1087    public List JavaDoc getPrincipalRoleRelatedPages(InfoGluePrincipal infoGluePrincipal, String JavaDoc roleName, String JavaDoc propertyName, boolean escapeHTML)
1088    {
1089        List JavaDoc pages = new ArrayList JavaDoc();
1090        
1091        try
1092        {
1093            if(getHasPrincipalRole(infoGluePrincipal, roleName))
1094            {
1095                List JavaDoc siteNodeVOList = GroupPropertiesController.getController().getRelatedSiteNodes(roleName, this.languageId, propertyName);
1096                
1097                Iterator JavaDoc i = siteNodeVOList.iterator();
1098                while(i.hasNext())
1099                {
1100                    SiteNodeVO siteNodeVO = (SiteNodeVO)i.next();
1101                    try
1102                    {
1103                        WebPage webPage = new WebPage();
1104                        webPage.setSiteNodeId(siteNodeVO.getSiteNodeId());
1105                        webPage.setLanguageId(this.languageId);
1106                        webPage.setContentId(null);
1107                        webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML));
1108                        webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext));
1109                        webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext));
1110                        pages.add(webPage);
1111                    }
1112                    catch(Exception JavaDoc e)
1113                    {
1114                        logger.info("An error occurred when looking up one of the related pages:" + e.getMessage(), e);
1115                    }
1116                }
1117            }
1118        }
1119        catch(Exception JavaDoc e)
1120        {
1121            logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
1122        }
1123        
1124        return pages;
1125    }
1126
1127    /**
1128     * Getting all categories assigned to a property for a Group - used for personalisation.
1129     */

1130    
1131    public List JavaDoc getPrincipalRoleCategories(String JavaDoc roleName, String JavaDoc propertyName)
1132    {
1133        return getPrincipalRoleCategories(this.infoGluePrincipal, roleName, propertyName);
1134    }
1135    
1136    /**
1137     * Getting all categories assigned to a property for a Group - used for personalisation.
1138     */

1139    
1140    public List JavaDoc getPrincipalRoleCategories(InfoGluePrincipal infoGluePrincipal, String JavaDoc roleName, String JavaDoc propertyName)
1141    {
1142        List JavaDoc categories = new ArrayList JavaDoc();
1143        
1144        try
1145        {
1146            if(getHasPrincipalRole(infoGluePrincipal, roleName))
1147                categories = GroupPropertiesController.getController().getRelatedCategories(roleName, this.languageId, propertyName);
1148        }
1149        catch(Exception JavaDoc e)
1150        {
1151            logger.warn("An error occurred trying to get property " + propertyName + " from infoGluePrincipal:" + e.getMessage(), e);
1152        }
1153        
1154        return categories;
1155    }
1156    
1157    /**
1158     * Getter for request-object
1159     */

1160    
1161    public HttpServletRequest JavaDoc getHttpServletRequest()
1162    {
1163        return this.request;
1164    }
1165
1166
1167    /**
1168     * Getter for request-parameters
1169     */

1170
1171    public Enumeration JavaDoc getRequestParamenterNames()
1172    {
1173        return this.request.getParameterNames();
1174    }
1175    
1176    /**
1177     * Getter for request-parameter
1178     */

1179    public String JavaDoc getRequestParameter(String JavaDoc parameterName)
1180    {
1181        String JavaDoc value = "";
1182        try
1183        {
1184            value = this.request.getParameter(parameterName);
1185            if(value == null)
1186                value = "";
1187        }
1188        catch(Exception JavaDoc e)
1189        {
1190            logger.warn("An error occurred trying to get parameterName " + parameterName + " from request:" + e.getMessage(), e);
1191        }
1192        
1193        return value;
1194    }
1195
1196    /**
1197     * Getter for request-parameters
1198     */

1199    public String JavaDoc[] getRequestParameterValues(String JavaDoc parameterName)
1200    {
1201        String JavaDoc value[] = null;
1202        try
1203        {
1204            value = this.request.getParameterValues(parameterName);
1205        }
1206        catch(Exception JavaDoc e)
1207        {
1208            logger.warn("An error occurred trying to get parameterName " + parameterName + " from request:" + e.getMessage(), e);
1209        }
1210        
1211        return value;
1212    }
1213    
1214    /**
1215     * Getter for the browserBean which supplies information about the users browser, OS and other stuff.
1216     */

1217    
1218    public BrowserBean getBrowserBean()
1219    {
1220        return browserBean;
1221    }
1222
1223    
1224    /**
1225     * Setting to enable us to set initialized versions of the Node and Content delivery Controllers.
1226     */

1227    public void setDeliveryControllers(NodeDeliveryController nodeDeliveryController, ContentDeliveryController contentDeliveryController, IntegrationDeliveryController integrationDeliveryController)
1228    {
1229        this.nodeDeliveryController = nodeDeliveryController;
1230        this.contentDeliveryController = contentDeliveryController;
1231        this.integrationDeliveryController = integrationDeliveryController;
1232    }
1233    
1234    /**
1235     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1236     * value if OnSiteEdit is on.
1237     */

1238     
1239    public String JavaDoc getContentAttribute(String JavaDoc contentBindningName, String JavaDoc attributeName, boolean clean)
1240    {
1241        return getContentAttribute(contentBindningName, attributeName);
1242    }
1243
1244    /**
1245     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1246     * value if OnSiteEdit is on.
1247     */

1248    public String JavaDoc getContentAttribute(String JavaDoc attributeName, boolean clean)
1249    {
1250        return getContentAttribute(attributeName);
1251    }
1252
1253    /**
1254     * This method deliveres a String with the content-attribute asked for a
1255     * specific content and ensure not to get decorated attributes if EditOnSite is
1256     * turned on.
1257     *
1258     * @param contentId
1259     * the contentId of a content
1260     * @param attributeName
1261     * the attribute name in the content. (ie. Title, Leadin etc)
1262     * @param clean
1263     * has no effect in this class.
1264     * @return the contentAttribute or empty string if none found.
1265     * @see org.infoglue.deliver.controllers.kernel.impl.simple.EditOnSiteTemplateController#getContentAttribute(java.lang.String,
1266     * boolean)
1267     */

1268    public String JavaDoc getContentAttribute(Integer JavaDoc contentId, String JavaDoc attributeName, boolean clean)
1269    {
1270        return getContentAttribute(contentId, attributeName);
1271    }
1272    
1273    /**
1274     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1275     * value if OnSiteEdit is on.
1276     */

1277 
1278    public String JavaDoc getContentAttribute(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName, boolean clean)
1279    {
1280        return getContentAttribute(contentId, languageId, attributeName);
1281    }
1282
1283    /**
1284     * This method deliveres a String with the content-attribute asked for in the language asked for.
1285     * As the siteNode can have multiple bindings as well as a content as a parameter this
1286     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1287     */

1288     
1289    public String JavaDoc getContentAttributeWithReturningId(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName, boolean clean, List JavaDoc contentVersionId)
1290    {
1291        return getContentAttribute(contentId, languageId, attributeName, contentVersionId);
1292    }
1293
1294    /**
1295     * This method deliveres a String with the content-attribute asked for if it exists in the content
1296     * defined in the url-parameter contentId.
1297     */

1298     
1299    public String JavaDoc getContentAttribute(String JavaDoc attributeName)
1300    {
1301        String JavaDoc attributeValue = "";
1302        
1303        try
1304        {
1305            attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), this.contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1306        }
1307        catch(Exception JavaDoc e)
1308        {
1309            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + this.contentId + ":" + e.getMessage(), e);
1310        }
1311                
1312        return attributeValue;
1313    }
1314
1315    /**
1316     * This method deliveres a String with the content-attribute asked for.
1317     * As the siteNode can have multiple bindings as well as a content as a parameter this
1318     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1319     */

1320     
1321    public String JavaDoc getContentAttribute(String JavaDoc contentBindningName, String JavaDoc attributeName)
1322    {
1323        String JavaDoc attributeValue = "";
1324        
1325        try
1326        {
1327            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1328            if(contentVO != null)
1329            {
1330                attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVO.getContentId(), this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1331            }
1332        }
1333        catch(Exception JavaDoc e)
1334        {
1335            logger.error("An error occurred trying to get attributeName=" + attributeName + " on contentBindning " + contentBindningName + ":" + e.getMessage(), e);
1336        }
1337                
1338        return attributeValue;
1339    }
1340
1341    
1342    /**
1343     * This method deliveres a String with the content-attribute asked for.
1344     * As the siteNode can have multiple bindings as well as a content as a parameter this
1345     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1346     */

1347     
1348    public String JavaDoc getContentAttribute(Integer JavaDoc contentId, String JavaDoc attributeName)
1349    {
1350        String JavaDoc attributeValue = "";
1351        
1352        this.deliveryContext.addUsedContent("content_" + contentId);
1353        
1354        try
1355        {
1356            attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1357        }
1358        catch(Exception JavaDoc e)
1359        {
1360            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e);
1361        }
1362                
1363        return attributeValue;
1364    }
1365
1366
1367    /**
1368     * This method deliveres a String with the content-attribute asked for in the language asked for.
1369     * As the siteNode can have multiple bindings as well as a content as a parameter this
1370     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1371     */

1372     
1373    public String JavaDoc getContentAttributeValue(Integer JavaDoc contentId, String JavaDoc attributeName, boolean escapeHTML)
1374    {
1375        return getContentAttributeValue(contentId, this.getLanguageId(), attributeName, escapeHTML);
1376    }
1377
1378    /**
1379     * This method deliveres a String with the content-attribute asked for in the language asked for.
1380     * As the siteNode can have multiple bindings as well as a content as a parameter this
1381     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1382     */

1383     
1384    public String JavaDoc getContentAttributeValue(Integer JavaDoc contentId, String JavaDoc attributeName, boolean clean, boolean escapeHTML)
1385    {
1386        return getContentAttributeValue(contentId, this.getLanguageId(), attributeName, escapeHTML);
1387    }
1388
1389    /**
1390     * This method deliveres a String with the content-attribute asked for in the language asked for.
1391     * As the siteNode can have multiple bindings as well as a content as a parameter this
1392     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1393     */

1394     
1395    public String JavaDoc getContentAttributeValue(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName, boolean escapeHTML)
1396    {
1397        String JavaDoc attributeValue = "";
1398        
1399        this.deliveryContext.addUsedContent("content_" + contentId);
1400        
1401        try
1402        {
1403            attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, escapeHTML);
1404        }
1405        catch(Exception JavaDoc e)
1406        {
1407            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e);
1408        }
1409                
1410        return attributeValue;
1411    }
1412
1413
1414
1415    /**
1416     * This method deliveres a String with the content-attribute asked for in the language asked for.
1417     * As the siteNode can have multiple bindings as well as a content as a parameter this
1418     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1419     */

1420     
1421    public String JavaDoc getContentAttribute(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName)
1422    {
1423        String JavaDoc attributeValue = "";
1424        
1425        this.deliveryContext.addUsedContent("content_" + contentId);
1426        
1427        try
1428        {
1429            attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1430        }
1431        catch(Exception JavaDoc e)
1432        {
1433            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e);
1434        }
1435                
1436        return attributeValue;
1437    }
1438    
1439    
1440    /**
1441     * This method deliveres a String with the content-attribute asked for in the language asked for.
1442     * As the siteNode can have multiple bindings as well as a content as a parameter this
1443     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1444     */

1445     
1446    public String JavaDoc getContentAttribute(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName, List JavaDoc contentVersionId)
1447    {
1448        String JavaDoc attributeValue = "";
1449        
1450        this.deliveryContext.addUsedContent("content_" + contentId);
1451        
1452        try
1453        {
1454            attributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false, contentVersionId);
1455        }
1456        catch(Exception JavaDoc e)
1457        {
1458            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e);
1459        }
1460                
1461        return attributeValue;
1462    }
1463
1464    /**
1465     * Finds an attribute on the provided ContentVersion.
1466     */

1467    public String JavaDoc getContentAttribute(ContentVersionVO version, String JavaDoc attributeName)
1468    {
1469        try
1470        {
1471            return ContentDeliveryController.getContentDeliveryController().getAttributeValue(getDatabase(), version, attributeName, false);
1472        }
1473        catch(Exception JavaDoc e)
1474        {
1475            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content version" + version.getId() + ":" + e.getMessage(), e);
1476        }
1477    
1478        return "";
1479    }
1480
1481    /**
1482     * This method deliveres a String with the content-attribute asked for in the language asked for.
1483     * If the attribute is not found in the language requested it fallbacks to the master language.
1484     */

1485
1486    public String JavaDoc getContentAttributeUsingLanguageFallback(Integer JavaDoc contentId, String JavaDoc attributeName, boolean disableEditOnSight)
1487    {
1488        logger.info("getContentAttributeUsingLanguageFallback: " + contentId + ":" + attributeName + ":" + disableEditOnSight);
1489        String JavaDoc attributeValue = "";
1490        
1491        try
1492        {
1493            attributeValue = this.getContentAttribute(contentId, attributeName, true);
1494            if(attributeValue != null && attributeValue.trim().equals(""))
1495            {
1496                LanguageVO masteLanguageVO = LanguageDeliveryController.getLanguageDeliveryController().getMasterLanguageForSiteNode(getDatabase(), this.siteNodeId);
1497                attributeValue = this.getContentAttribute(contentId, masteLanguageVO.getLanguageId(), attributeName, disableEditOnSight);
1498            }
1499        }
1500        catch(Exception JavaDoc e)
1501        {
1502            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content " + contentId + ":" + e.getMessage(), e);
1503        }
1504                
1505        return attributeValue;
1506    }
1507    
1508    /**
1509     * This method deliveres a String with the content-attribute asked for after it has been parsed and all special tags have been converted.
1510     * As the siteNode can have multiple bindings as well as a content as a parameter this
1511     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1512     */

1513     
1514    public String JavaDoc getParsedContentAttribute(String JavaDoc attributeName)
1515    {
1516        String JavaDoc attributeValue = "";
1517        
1518        try
1519        {
1520            if(this.contentId != null)
1521            {
1522                String JavaDoc unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), this.contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1523                logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue);
1524                
1525                templateLogicContext.put("inlineContentId", this.contentId);
1526                
1527                Map JavaDoc context = new HashMap JavaDoc();
1528                context.put("inheritedTemplateLogic", this);
1529                context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext));
1530                
1531                // Add the templateLogicContext objects to this context. (SS - 040219)
1532
context.putAll(templateLogicContext);
1533                
1534                StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
1535                PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
1536                new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true);
1537                attributeValue = cacheString.toString();
1538                //logger.info("result:" + result);
1539
}
1540        }
1541        catch(Exception JavaDoc e)
1542        {
1543            logger.error("An error occurred trying to get attributeName=" + attributeName + " on sent in content with id:" + this.contentId + ":" + e.getMessage(), e);
1544        }
1545                
1546        return attributeValue;
1547    }
1548
1549
1550    /**
1551     * This method deliveres a String with the content-attribute asked for after it has been parsed and all special tags have been converted.
1552     * As the siteNode can have multiple bindings as well as a content as a parameter this
1553     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1554     */

1555     
1556    public String JavaDoc getParsedContentAttribute(String JavaDoc contentBindningName, String JavaDoc attributeName)
1557    {
1558        logger.info("getParsedContentAttribute:" + contentBindningName + ":" + attributeName);
1559        
1560        String JavaDoc attributeValue = "";
1561        
1562        try
1563        {
1564            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1565            if(contentVO != null)
1566            {
1567                logger.info("contentVO:" + contentVO.getContentId());
1568        
1569                String JavaDoc unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVO.getId(), this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1570                logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue);
1571                            
1572                templateLogicContext.put("inlineContentId", contentVO.getId());
1573                
1574                Map JavaDoc context = new HashMap JavaDoc();
1575                context.put("inheritedTemplateLogic", this);
1576                context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, contentVO.getId(), this.request, this.infoGluePrincipal, this.deliveryContext));
1577                
1578                // Add the templateLogicContext objects to this context. (SS - 040219)
1579
context.putAll(templateLogicContext);
1580                                
1581                StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
1582                PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
1583                new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true);
1584                attributeValue = cacheString.toString();
1585            }
1586        }
1587        catch(Exception JavaDoc e)
1588        {
1589            logger.error("An error occurred trying to get attributeName=" + attributeName + " on contentBindning " + contentBindningName + ":" + e.getMessage(), e);
1590        }
1591                
1592        return attributeValue;
1593    }
1594
1595    
1596
1597    /**
1598     * This method deliveres a String with the content-attribute asked for after it has been parsed and all special tags have been converted.
1599     * The attribute is fetched from the specified content.
1600     */

1601     
1602    public String JavaDoc getParsedContentAttribute(Integer JavaDoc contentId, String JavaDoc attributeName)
1603    {
1604        String JavaDoc attributeValue = "";
1605        
1606        try
1607        {
1608            if(contentId != null)
1609            {
1610                String JavaDoc unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, this.languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1611                logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue);
1612                
1613                templateLogicContext.put("inlineContentId", contentId);
1614                
1615                Map JavaDoc context = new HashMap JavaDoc();
1616                context.put("inheritedTemplateLogic", this);
1617                context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, contentId, this.request, this.infoGluePrincipal, this.deliveryContext));
1618
1619                // Add the templateLogicContext objects to this context. (SS - 040219)
1620
context.putAll(templateLogicContext);
1621                
1622                StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
1623                PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
1624                new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true);
1625                attributeValue = cacheString.toString();
1626            }
1627        }
1628        catch(Exception JavaDoc e)
1629        {
1630            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content with id " + contentId + ":" + e.getMessage(), e);
1631        }
1632                
1633        return attributeValue;
1634    }
1635
1636    /**
1637     * This method deliveres a String with the content-attribute asked for after it has been parsed and all special tags have been converted.
1638     * The attribute is fetched from the specified content.
1639     */

1640     
1641    public String JavaDoc getParsedContentAttribute(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName)
1642    {
1643        String JavaDoc attributeValue = "";
1644        
1645        try
1646        {
1647            if(contentId != null)
1648            {
1649                String JavaDoc unparsedAttributeValue = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentId, languageId, attributeName, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
1650                logger.info("Found unparsedAttributeValue:" + unparsedAttributeValue);
1651                
1652                templateLogicContext.put("inlineContentId", contentId);
1653                
1654                Map JavaDoc context = new HashMap JavaDoc();
1655                context.put("inheritedTemplateLogic", this);
1656                context.put("templateLogic", getTemplateController(this.siteNodeId, languageId, contentId, this.request, this.infoGluePrincipal, this.deliveryContext));
1657
1658                // Add the templateLogicContext objects to this context. (SS - 040219)
1659
context.putAll(templateLogicContext);
1660                
1661                StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
1662                PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
1663                new VelocityTemplateProcessor().renderTemplate(context, cachedStream, unparsedAttributeValue, true);
1664                attributeValue = cacheString.toString();
1665            }
1666        }
1667        catch(Exception JavaDoc e)
1668        {
1669            logger.error("An error occurred trying to get attributeName=" + attributeName + " on content with id " + contentId + ":" + e.getMessage(), e);
1670        }
1671                
1672        return attributeValue;
1673    }
1674
1675    /**
1676     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1677     * value if OnSiteEdit is on.
1678     */

1679     
1680    public String JavaDoc getParsedContentAttribute(String JavaDoc attributeName, boolean clean)
1681    {
1682        return getParsedContentAttribute(attributeName);
1683    }
1684
1685    /**
1686     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1687     * value if OnSiteEdit is on.
1688     */

1689
1690    public String JavaDoc getParsedContentAttribute(String JavaDoc contentBindningName, String JavaDoc attributeName, boolean clean)
1691    {
1692        return getParsedContentAttribute(contentBindningName, attributeName);
1693    }
1694
1695    /**
1696     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1697     * value if OnSiteEdit is on.
1698     */

1699
1700    public String JavaDoc getParsedContentAttribute(Integer JavaDoc contentId, String JavaDoc attributeName, boolean clean)
1701    {
1702        return getParsedContentAttribute(contentId, attributeName);
1703    }
1704
1705    /**
1706     * This method is just a dummy method used to ensure that we can ensure to not get a decorated attribute
1707     * value if OnSiteEdit is on.
1708     */

1709
1710    public String JavaDoc getParsedContentAttribute(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName, boolean clean)
1711    {
1712        return getParsedContentAttribute(contentId, languageId, attributeName);
1713    }
1714
1715    /**
1716     * This method deliveres a list of strings which represents all assetKeys for a content.
1717     */

1718     
1719    public Collection JavaDoc getAssetKeys(String JavaDoc contentBindningName)
1720    {
1721        Collection JavaDoc assetKeys = new ArrayList JavaDoc();
1722        
1723        try
1724        {
1725            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1726            assetKeys = ContentDeliveryController.getContentDeliveryController().getAssetKeys(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1727        }
1728        catch(Exception JavaDoc e)
1729        {
1730            logger.error("An error occurred trying to get assetKeys on content with id: " + contentId + ":" + e.getMessage(), e);
1731        }
1732                
1733        return assetKeys;
1734    }
1735
1736    /**
1737     * This method deliveres a list of strings which represents all assetKeys for a content.
1738     */

1739     
1740    public Collection JavaDoc getAssetKeys(Integer JavaDoc contentId)
1741    {
1742        Collection JavaDoc assetKeys = new ArrayList JavaDoc();
1743        
1744        try
1745        {
1746            assetKeys = ContentDeliveryController.getContentDeliveryController().getAssetKeys(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1747        }
1748        catch(Exception JavaDoc e)
1749        {
1750            logger.error("An error occurred trying to get assetKeys on content with id: " + contentId + ":" + e.getMessage(), e);
1751        }
1752                
1753        return assetKeys;
1754    }
1755    
1756    /**
1757     * This method deliveres a list of strings which represents all assetKeys defined for a contentTypeDefinition.
1758     */

1759     
1760    public Collection JavaDoc getContentTypeDefinitionAssetKeys(String JavaDoc schemaValue)
1761    {
1762        Collection JavaDoc assetKeys = new ArrayList JavaDoc();
1763        
1764        try
1765        {
1766            assetKeys = ContentTypeDefinitionController.getController().getDefinedAssetKeys(schemaValue);
1767        }
1768        catch(Exception JavaDoc e)
1769        {
1770            logger.error("An error occurred trying to get assetKeys on content with id: " + contentId + ":" + e.getMessage(), e);
1771        }
1772                
1773        return assetKeys;
1774    }
1775 
1776    /**
1777     * This method deliveres a String with the URL to the thumbnail for the digital asset asked for.
1778     * This method assumes that the content sent in only has one asset attached.
1779     */

1780     
1781    public String JavaDoc getAssetThumbnailUrl(Integer JavaDoc contentId, int width, int height)
1782    {
1783        String JavaDoc assetThumbnailUrl = "";
1784        
1785        try
1786        {
1787            assetThumbnailUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal);
1788        }
1789        catch(Exception JavaDoc e)
1790        {
1791            logger.error("An error occurred trying to get assetThumbnailUrl on contentId " + contentId + ":" + e.getMessage(), e);
1792        }
1793                
1794        return assetThumbnailUrl;
1795    }
1796
1797    /**
1798     * This method deliveres a String with the URL to the thumbnail for the digital asset asked for.
1799     * This method takes a key for the asset you want to make a thumbnail from.
1800     */

1801     
1802    public String JavaDoc getAssetThumbnailUrl(Integer JavaDoc contentId, String JavaDoc assetKey, int width, int height)
1803    {
1804        String JavaDoc assetThumbnailUrl = "";
1805        
1806        try
1807        {
1808            assetThumbnailUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal);
1809        }
1810        catch(Exception JavaDoc e)
1811        {
1812            logger.error("An error occurred trying to get assetThumbnailUrl on contentId " + contentId + ":" + e.getMessage(), e);
1813        }
1814                
1815        return assetThumbnailUrl;
1816    }
1817
1818    /**
1819     * This method deliveres a String with the URL to the thumbnail of the digital asset asked for.
1820     * As the siteNode can have multiple bindings as well as a content as a parameter this
1821     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1822     */

1823     
1824    public String JavaDoc getAssetThumbnailUrl(String JavaDoc contentBindningName, int width, int height)
1825    {
1826        String JavaDoc assetUrl = "";
1827        
1828        try
1829        {
1830            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1831            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal);
1832        }
1833        catch(Exception JavaDoc e)
1834        {
1835            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
1836        }
1837                
1838        return assetUrl;
1839    }
1840
1841    /**
1842     * This method deliveres a String with the URL to the thumbnail of the digital asset asked for.
1843     * As the siteNode can have multiple bindings as well as a content as a parameter this
1844     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1845     */

1846     
1847    public String JavaDoc getAssetThumbnailUrl(String JavaDoc contentBindningName, String JavaDoc assetKey, int width, int height)
1848    {
1849        String JavaDoc assetThumbnailUrl = "";
1850        
1851        try
1852        {
1853            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1854            assetThumbnailUrl = ContentDeliveryController.getContentDeliveryController().getAssetThumbnailUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, width, height, this.deliveryContext, this.infoGluePrincipal);
1855        }
1856        catch(Exception JavaDoc e)
1857        {
1858            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
1859        }
1860                
1861        return assetThumbnailUrl;
1862    }
1863
1864    /**
1865     * This method deliveres a String with the URL to the digital asset asked for.
1866     * As the siteNode can have multiple bindings as well as a content as a parameter this
1867     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1868     */

1869     
1870    public String JavaDoc getAssetUrl(String JavaDoc contentBindningName)
1871    {
1872        String JavaDoc assetUrl = "";
1873        
1874        try
1875        {
1876            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1877            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1878        }
1879        catch(Exception JavaDoc e)
1880        {
1881            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
1882        }
1883                
1884        return assetUrl;
1885    }
1886
1887    
1888    public String JavaDoc getEncodedUrl(String JavaDoc s, String JavaDoc enc)
1889    {
1890        String JavaDoc ret = "";
1891        try
1892        {
1893            ret = java.net.URLEncoder.encode(s, enc);
1894        }
1895        catch (UnsupportedEncodingException JavaDoc e)
1896        {
1897            logger.error("An error occurred trying to encode the url: " + s + " with encoding: " + enc + ": " + e.getMessage(), e);
1898        }
1899        return ret;
1900    }
1901    
1902    /**
1903     * This method deliveres a String with the URL to the digital asset asked for.
1904     */

1905     
1906    public String JavaDoc getAssetUrl(Integer JavaDoc contentId)
1907    {
1908        String JavaDoc assetUrl = "";
1909        
1910        try
1911        {
1912            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1913        }
1914        catch(Exception JavaDoc e)
1915        {
1916            logger.error("An error occurred trying to get assetUrl on content with id: " + contentId + ":" + e.getMessage(), e);
1917        }
1918                
1919        return assetUrl;
1920    }
1921
1922
1923    /**
1924     * This method deliveres a String with the URL to the digital asset asked for.
1925     */

1926     
1927    public String JavaDoc getAssetUrl(Integer JavaDoc contentId, String JavaDoc assetKey)
1928    {
1929        String JavaDoc assetUrl = "";
1930        
1931        try
1932        {
1933            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1934        }
1935        catch(Exception JavaDoc e)
1936        {
1937            logger.error("An error occurred trying to get assetUrl on content with id: " + contentId + " and assetKey:" + assetKey + " : " + e.getMessage(), e);
1938        }
1939                
1940        return assetUrl;
1941    }
1942
1943
1944    /**
1945     * This method deliveres a String with the URL to the digital asset asked for.
1946     * As the siteNode can have multiple bindings as well as a content as a parameter this
1947     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1948     */

1949     
1950    public String JavaDoc getAssetUrl(String JavaDoc contentBindningName, int index)
1951    {
1952        String JavaDoc assetUrl = "";
1953        
1954        try
1955        {
1956            List JavaDoc contentVOList = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, USE_INHERITANCE, true, this.deliveryContext);
1957            if(contentVOList != null && contentVOList.size() > index)
1958            {
1959                ContentVO contentVO = (ContentVO)contentVOList.get(index);
1960                assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1961            }
1962        }
1963        catch(Exception JavaDoc e)
1964        {
1965            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
1966        }
1967                
1968        return assetUrl;
1969    }
1970
1971
1972    /**
1973     * This method deliveres a String with the URL to the digital asset asked for.
1974     * As the siteNode can have multiple bindings as well as a content as a parameter this
1975     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
1976     */

1977     
1978    public String JavaDoc getAssetUrl(String JavaDoc contentBindningName, String JavaDoc assetKey)
1979    {
1980        String JavaDoc assetUrl = "";
1981        
1982        try
1983        {
1984            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
1985            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
1986        }
1987        catch(Exception JavaDoc e)
1988        {
1989            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e);
1990        }
1991                
1992        return assetUrl;
1993    }
1994
1995
1996    /**
1997     * This method deliveres a String with the URL to the digital asset asked for.
1998     * As the siteNode can have multiple bindings as well as a content as a parameter this
1999     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
2000     */

2001     
2002    public String JavaDoc getAssetUrl(InfoGluePrincipal principal, String JavaDoc assetKey, Integer JavaDoc languageId, Integer JavaDoc siteNodeId, boolean useLanguageFallback)
2003    {
2004        String JavaDoc assetUrl = "";
2005        
2006        try
2007        {
2008            assetUrl = ExtranetController.getController().getPrincipalAssetUrl(this.getDatabase(), principal, assetKey, languageId, siteNodeId, useLanguageFallback, deliveryContext);
2009        }
2010        catch(Exception JavaDoc e)
2011        {
2012            logger.error("An error occurred trying to get assetUrl on principal " + principal.getName() + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2013        }
2014                
2015        return assetUrl;
2016    }
2017    
2018    /**
2019     * This method deliveres a String with the URL to the digital asset asked for.
2020     * As the siteNode can have multiple bindings as well as a content as a parameter this
2021     * parameter requires a bindingName which refers to the AvailableServiceBinding.name-attribute.
2022     */

2023     
2024    public String JavaDoc getAssetThumbnailUrl(InfoGluePrincipal principal, String JavaDoc assetKey, Integer JavaDoc languageId, Integer JavaDoc siteNodeId, boolean useLanguageFallback, int width, int height)
2025    {
2026        String JavaDoc assetUrl = "";
2027        
2028        try
2029        {
2030            assetUrl = ExtranetController.getController().getPrincipalThumbnailAssetUrl(this.getDatabase(), principal, assetKey, languageId, siteNodeId, useLanguageFallback, width, height, deliveryContext);
2031        }
2032        catch(Exception JavaDoc e)
2033        {
2034            logger.error("An error occurred trying to get assetUrl on principal " + principal.getName() + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2035        }
2036                
2037        return assetUrl;
2038    }
2039    
2040    /**
2041     * This method deliveres a String with the URL to the digital asset asked for. In this special case the image
2042     * is fetched from the article being generated. This means that this method only is of interest if you have attached
2043     * assets to either a template or to an content and are useing parsedContentAttribute.
2044     */

2045     
2046    public String JavaDoc getInlineAssetUrl(String JavaDoc assetKey)
2047    {
2048        String JavaDoc assetUrl = "";
2049        
2050        try
2051        {
2052            Integer JavaDoc inlineContentId = this.contentId;
2053            if(inlineContentId == null || inlineContentId.intValue() == -1)
2054                inlineContentId = (Integer JavaDoc)this.templateLogicContext.get("inlineContentId");
2055                
2056            logger.info("getInlineAssetUrl:" + inlineContentId + ":" + this.languageId + ":" + assetKey + ":" + this.siteNodeId);
2057            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), inlineContentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2058        }
2059        catch(Exception JavaDoc e)
2060        {
2061            logger.error("An error occurred trying to get assetUrl on content with id: " + this.contentId + ":" + e.getMessage(), e);
2062        }
2063                
2064        return assetUrl;
2065    }
2066
2067
2068    /**
2069     * This method deliveres a String with the URL to the digital asset asked for. In this special case the image
2070     * is fetched from the article being generated. This means that this method only is of interest if you have attached
2071     * assets to either a template or to an content and are useing parsedContentAttribute.
2072     */

2073     
2074    public String JavaDoc getInlineAssetUrl(Integer JavaDoc contentId, String JavaDoc assetKey)
2075    {
2076        String JavaDoc assetUrl = "";
2077        
2078        try
2079        {
2080            Integer JavaDoc inlineContentId = contentId;
2081            logger.info("getInlineAssetUrl:" + inlineContentId + ":" + this.languageId + ":" + assetKey + ":" + this.siteNodeId);
2082            assetUrl = ContentDeliveryController.getContentDeliveryController().getAssetUrl(getDatabase(), inlineContentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2083        }
2084        catch(Exception JavaDoc e)
2085        {
2086            logger.error("An error occurred trying to get assetUrl on content with id: " + this.contentId + ":" + e.getMessage(), e);
2087        }
2088                
2089        return assetUrl;
2090    }
2091
2092    /*
2093     * Provide the same interface for getting asset filesize as for getting url.
2094     * This should be refactored soon, to supply a assetVO instead.
2095     *
2096     */

2097
2098    public Integer JavaDoc getAssetFileSize(Integer JavaDoc contentId)
2099    {
2100        Integer JavaDoc AssetFileSize = null;
2101        try
2102        {
2103            AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentId, this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2104        }
2105        catch(Exception JavaDoc e)
2106        {
2107            logger.error("An error occurred trying to get AssetFileSize on content with id: " + contentId + ":" + e.getMessage(), e);
2108        }
2109        return AssetFileSize;
2110    }
2111    
2112    public Integer JavaDoc getAssetFileSize(Integer JavaDoc contentId, String JavaDoc assetKey)
2113    {
2114        Integer JavaDoc AssetFileSize = null;
2115        try
2116        {
2117            AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2118        }
2119        catch(Exception JavaDoc e)
2120        {
2121            logger.error("An error occurred trying to get AssetFileSize on content with id: " + contentId + " and assetKey:" + assetKey + " : " + e.getMessage(), e);
2122        }
2123        return AssetFileSize;
2124    }
2125    
2126    public Integer JavaDoc getAssetFileSize(String JavaDoc contentBindningName, int index)
2127    {
2128        Integer JavaDoc AssetFileSize = null;
2129        try
2130        {
2131            List JavaDoc contentVOList = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, USE_INHERITANCE, true, this.deliveryContext);
2132            if(contentVOList != null && contentVOList.size() > index)
2133            {
2134                ContentVO contentVO = (ContentVO)contentVOList.get(index);
2135                AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentVO.getContentId(), this.languageId, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2136            }
2137        }
2138        catch(Exception JavaDoc e)
2139        {
2140            logger.error("An error occurred trying to get AssetFileSize on contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
2141        }
2142        return AssetFileSize;
2143    }
2144    
2145    public Integer JavaDoc getAssetFileSize(String JavaDoc contentBindningName, String JavaDoc assetKey)
2146    {
2147        Integer JavaDoc AssetFileSize = null;
2148        try
2149        {
2150            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
2151            AssetFileSize = ContentDeliveryController.getContentDeliveryController().getAssetFileSize(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2152        }
2153        catch(Exception JavaDoc e)
2154        {
2155            logger.error("An error occurred trying to get AssetFileSize on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2156        }
2157        return AssetFileSize;
2158    }
2159
2160    
2161    /**
2162     * This method gets a List of related contents defined in an attribute as an xml-definition.
2163     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2164     * used to access other systems than our own.
2165     */

2166    
2167    public List JavaDoc getRelatedContentsByQualifyer(String JavaDoc qualifyerXML)
2168    {
2169        List JavaDoc relatedContentVOList = new ArrayList JavaDoc();
2170        
2171        try
2172        {
2173            relatedContentVOList = this.getRelatedContentsFromXML(qualifyerXML);
2174        }
2175        catch(Exception JavaDoc e)
2176        {
2177            logger.error("An error occurred trying to get related contents from qualifyer: " + qualifyerXML + ":" + e.getMessage(), e);
2178        }
2179        
2180        return relatedContentVOList;
2181    }
2182
2183    /**
2184     * This method gets a List of related contents defined in an attribute as an xml-definition.
2185     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2186     * used to access other systems than our own.
2187     */

2188    
2189    public List JavaDoc getRelatedContents(String JavaDoc attributeName)
2190    {
2191        List JavaDoc relatedContentVOList = new ArrayList JavaDoc();
2192        
2193        try
2194        {
2195            String JavaDoc qualifyerXML = this.getContentAttribute(attributeName, true);
2196            
2197            relatedContentVOList = this.getRelatedContentsFromXML(qualifyerXML);
2198        }
2199        catch(Exception JavaDoc e)
2200        {
2201            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2202        }
2203        
2204        return relatedContentVOList;
2205    }
2206    
2207    /**
2208     * This method gets a List of related contents defined in an attribute as an xml-definition.
2209     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2210     * used to access other systems than our own.
2211     */

2212    
2213    public List JavaDoc getRelatedContents(String JavaDoc bindingName, String JavaDoc attributeName)
2214    {
2215        List JavaDoc relatedContentVOList = new ArrayList JavaDoc();
2216        
2217        try
2218        {
2219            String JavaDoc qualifyerXML = this.getContentAttribute(bindingName, attributeName, true);
2220
2221            relatedContentVOList = this.getRelatedContentsFromXML(qualifyerXML);
2222        }
2223        catch(Exception JavaDoc e)
2224        {
2225            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2226        }
2227        
2228        return relatedContentVOList;
2229    }
2230
2231    
2232    
2233    /**
2234     * This method gets a List of related contents defined in an attribute as an xml-definition.
2235     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2236     * used to access other systems than our own.
2237     */

2238    
2239    public List JavaDoc getRelatedContents(Integer JavaDoc contentId, String JavaDoc attributeName)
2240    {
2241        List JavaDoc relatedContentVOList = new ArrayList JavaDoc();
2242        
2243        try
2244        {
2245            logger.info("contentId " + this.contentId + " with relationName " + attributeName);
2246            String JavaDoc qualifyerXML = this.getContentAttribute(contentId, attributeName, true);
2247            
2248            relatedContentVOList = getRelatedContentsFromXML(qualifyerXML);
2249        }
2250        catch(Exception JavaDoc e)
2251        {
2252            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2253        }
2254        
2255        return relatedContentVOList;
2256    }
2257
2258    /**
2259     * This method gets a List of related contents defined in a principal property as an xml-definition.
2260     */

2261    
2262    public List JavaDoc getRelatedContents(InfoGluePrincipal infogluePrincipal, String JavaDoc attributeName)
2263    {
2264        List JavaDoc relatedContentVOList = new ArrayList JavaDoc();
2265        
2266        try
2267        {
2268            String JavaDoc qualifyerXML = this.getPrincipalPropertyValue(infogluePrincipal, attributeName, false);
2269            
2270            relatedContentVOList = getRelatedContentsFromXML(qualifyerXML);
2271        }
2272        catch(Exception JavaDoc e)
2273        {
2274            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2275        }
2276        
2277        return relatedContentVOList;
2278    }
2279
2280    
2281    /**
2282     * This method gets the related contents from an XML.
2283     */

2284    
2285    private List JavaDoc getRelatedContentsFromXML(String JavaDoc qualifyerXML)
2286    {
2287        List JavaDoc relatedContentVOList = new ArrayList JavaDoc();
2288
2289        try
2290        {
2291            if(qualifyerXML != null && !qualifyerXML.equals(""))
2292            {
2293                Document document = new DOMBuilder().getDocument(qualifyerXML);
2294                                
2295                List JavaDoc children = document.getRootElement().elements();
2296                Iterator JavaDoc i = children.iterator();
2297                while(i.hasNext())
2298                {
2299                    Element child = (Element)i.next();
2300                    
2301                    String JavaDoc id = child.attributeValue("id");
2302                    if(id == null || id.equals(""))
2303                        id = child.getText();
2304        
2305                    ContentVO contentVO = this.getContent(new Integer JavaDoc(id));
2306                    if(ContentDeliveryController.getContentDeliveryController().isValidContent(this.getDatabase(), contentVO.getId(), this.languageId, USE_LANGUAGE_FALLBACK, true, getPrincipal(), this.deliveryContext))
2307                        relatedContentVOList.add(contentVO);
2308                }
2309            }
2310        }
2311        catch(Exception JavaDoc e)
2312        {
2313            logger.error("An error occurred trying to get related contents from qualifyerXML " + qualifyerXML + ":" + e.getMessage(), e);
2314        }
2315
2316        return relatedContentVOList;
2317    }
2318
2319    /**
2320     * This method gets the related pages from an XML.
2321     */

2322    
2323    private List JavaDoc getRelatedPagesFromXML(String JavaDoc qualifyerXML, boolean escapeHTML)
2324    {
2325        List JavaDoc relatedPages = new ArrayList JavaDoc();
2326        
2327        try
2328        {
2329            if(qualifyerXML != null && !qualifyerXML.equals(""))
2330            {
2331                Document document = new DOMBuilder().getDocument(qualifyerXML);
2332                                
2333                List JavaDoc children = document.getRootElement().elements();
2334                Iterator JavaDoc i = children.iterator();
2335                while(i.hasNext())
2336                {
2337                    Element child = (Element)i.next();
2338                    
2339                    String JavaDoc id = child.attributeValue("id");
2340                    if(id == null || id.equals(""))
2341                        id = child.getText();
2342        
2343                    try
2344                    {
2345                        SiteNodeVO siteNodeVO = this.nodeDeliveryController.getSiteNode(getDatabase(), new Integer JavaDoc(id)).getValueObject();
2346                        if(this.nodeDeliveryController.isValidSiteNode(getDatabase(), siteNodeVO.getId()))
2347                        {
2348                            WebPage webPage = new WebPage();
2349                            webPage.setSiteNodeId(siteNodeVO.getSiteNodeId());
2350                            webPage.setLanguageId(this.languageId);
2351                            webPage.setContentId(null);
2352                            webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML));
2353                            webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext));
2354                            webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext));
2355                            relatedPages.add(webPage);
2356                        }
2357                    }
2358                    catch(Exception JavaDoc e)
2359                    {
2360                        logger.info("An error occurred when looking up one of the related Pages FromXML:" + e.getMessage(), e);
2361                    }
2362                }
2363            }
2364        }
2365        catch(Exception JavaDoc e)
2366        {
2367            logger.error("An error occurred trying to get related contents from qualifyerXML " + qualifyerXML + ":" + e.getMessage(), e);
2368        }
2369
2370        return relatedPages;
2371    }
2372    /**
2373     * This method gets a List of related siteNodes defined in an attribute as an xml-definition.
2374     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2375     * used to access other systems than our own.
2376     */

2377    
2378    public List JavaDoc getRelatedPages(String JavaDoc attributeName)
2379    {
2380        return getRelatedPages(attributeName, false);
2381    }
2382
2383    /**
2384     * This method gets a List of related siteNodes defined in an attribute as an xml-definition.
2385     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2386     * used to access other systems than our own.
2387     */

2388    
2389    public List JavaDoc getRelatedPages(String JavaDoc attributeName, boolean escapeHTML)
2390    {
2391        List JavaDoc relatedPages = new ArrayList JavaDoc();
2392        
2393        try
2394        {
2395            String JavaDoc qualifyerXML = this.getContentAttribute(attributeName, true);
2396            
2397            relatedPages = getRelatedPagesFromXML(qualifyerXML, escapeHTML);
2398        }
2399        catch(Exception JavaDoc e)
2400        {
2401            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2402        }
2403        
2404        return relatedPages;
2405    }
2406
2407    /**
2408     * This method gets a List of related contents defined in an attribute as an xml-definition.
2409     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2410     * used to access other systems than our own.
2411     */

2412
2413    public List JavaDoc getRelatedPages(String JavaDoc bindingName, String JavaDoc attributeName)
2414    {
2415        return getRelatedPages(bindingName, attributeName, false);
2416    }
2417
2418    /**
2419     * This method gets a List of related contents defined in an attribute as an xml-definition.
2420     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2421     * used to access other systems than our own.
2422     */

2423
2424    public List JavaDoc getRelatedPages(String JavaDoc bindingName, String JavaDoc attributeName, boolean escapeHTML)
2425    {
2426        List JavaDoc relatedPages = new ArrayList JavaDoc();
2427        
2428        try
2429        {
2430            String JavaDoc qualifyerXML = this.getContentAttribute(bindingName, attributeName, true);
2431
2432            relatedPages = getRelatedPagesFromXML(qualifyerXML, escapeHTML);
2433        }
2434        catch(Exception JavaDoc e)
2435        {
2436            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2437        }
2438        
2439        return relatedPages;
2440    }
2441    
2442
2443    /**
2444     * This method gets a List of related contents defined in an attribute as an xml-definition.
2445     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2446     * used to access other systems than our own.
2447     */

2448
2449    public List JavaDoc getRelatedPages(Integer JavaDoc contentId, String JavaDoc attributeName)
2450    {
2451        List JavaDoc relatedPages = new ArrayList JavaDoc();
2452        
2453        try
2454        {
2455            String JavaDoc qualifyerXML = this.getContentAttribute(contentId, attributeName, true);
2456            
2457            relatedPages = getRelatedPagesFromXML(qualifyerXML, false);
2458        }
2459        catch(Exception JavaDoc e)
2460        {
2461            logger.error("An error occurred trying to get related contents on contentId " + this.contentId + " with relationName " + attributeName + ":" + e.getMessage(), e);
2462        }
2463        
2464        return relatedPages;
2465    }
2466
2467    /**
2468     * This method gets a List of related contents defined in an attribute as an xml-definition.
2469     * This is an ugly method right now. Later we should have xmlDefinitions that are fully qualified so it can be
2470     * used to access other systems than our own.
2471     */

2472
2473    public List JavaDoc getRelatedPages(InfoGluePrincipal infogluePrincipal, String JavaDoc attributeName)
2474    {
2475        List JavaDoc relatedPages = new ArrayList JavaDoc();
2476        
2477        try
2478        {
2479            String JavaDoc qualifyerXML = this.getPrincipalPropertyValue(infogluePrincipal, attributeName, false);
2480            
2481            relatedPages = getRelatedPagesFromXML(qualifyerXML, false);
2482        }
2483        catch(Exception JavaDoc e)
2484        {
2485            logger.error("An error occurred trying to get related pages on infogluePrincipal " + infogluePrincipal + " with relationName " + attributeName + ":" + e.getMessage(), e);
2486        }
2487        
2488        return relatedPages;
2489    }
2490
2491
2492    /**
2493     * This method deliveres a String with the URL to the base path of the directory resulting from
2494     * an unpacking of a uploaded zip-digitalAsset.
2495     */

2496     
2497    public String JavaDoc getArchiveBaseUrl(String JavaDoc contentBindningName, String JavaDoc assetKey)
2498    {
2499        String JavaDoc assetUrl = "";
2500        
2501        try
2502        {
2503            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
2504            assetUrl = ContentDeliveryController.getContentDeliveryController().getArchiveBaseUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2505        }
2506        catch(Exception JavaDoc e)
2507        {
2508            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2509        }
2510                
2511        return assetUrl;
2512    }
2513
2514    
2515    /**
2516     * This method deliveres a String with the URL to the base path of the directory resulting from
2517     * an unpacking of a uploaded zip-digitalAsset.
2518     */

2519     
2520    public String JavaDoc getArchiveBaseUrl(Integer JavaDoc contentId, String JavaDoc assetKey)
2521    {
2522        String JavaDoc assetUrl = "";
2523        
2524        try
2525        {
2526            assetUrl = ContentDeliveryController.getContentDeliveryController().getArchiveBaseUrl(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2527        }
2528        catch(Exception JavaDoc e)
2529        {
2530            logger.error("An error occurred trying to get assetUrl on content with id " + contentId + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2531        }
2532                
2533        return assetUrl;
2534    }
2535
2536    public Vector JavaDoc getArchiveEntries(Integer JavaDoc contentId, String JavaDoc assetKey)
2537    {
2538        Vector JavaDoc entries = null;
2539        
2540        try
2541        {
2542            entries = ContentDeliveryController.getContentDeliveryController().getArchiveEntries(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2543        }
2544        catch(Exception JavaDoc e)
2545        {
2546            logger.error("An error occurred trying to get assetUrl on content with id " + contentId + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2547        }
2548                
2549        return entries;
2550    }
2551
2552
2553    /**
2554     * This method deliveres a String with the URL to the base path of the directory resulting from
2555     * an unpacking of a uploaded zip-digitalAsset.
2556     */

2557     
2558    public String JavaDoc getArchiveBaseUrl(String JavaDoc contentBindningName, int index, String JavaDoc assetKey)
2559    {
2560        String JavaDoc assetUrl = "";
2561        
2562        try
2563        {
2564            List JavaDoc contentVOList = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, USE_INHERITANCE, true, this.deliveryContext);
2565            if(contentVOList != null && contentVOList.size() > index)
2566            {
2567                ContentVO contentVO = (ContentVO)contentVOList.get(index);
2568                assetUrl = ContentDeliveryController.getContentDeliveryController().getArchiveBaseUrl(getDatabase(), contentVO.getContentId(), this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2569            }
2570        }
2571        catch(Exception JavaDoc e)
2572        {
2573            logger.error("An error occurred trying to get assetUrl on contentBindningName " + contentBindningName + " with assetKey " + assetKey + ":" + e.getMessage(), e);
2574        }
2575                
2576        return assetUrl;
2577    }
2578
2579
2580    
2581    /**
2582     * This method uses the content-attribute to generate a pdf-file.
2583     * The content-attribute is parsed before it is sent to the renderer, and the
2584     * resulting string must follow the XSL-FO specification.
2585     *
2586     * The method checks if a previous file exists that has the same attributes as the wanted one
2587     * and if so - we don't generate it again.
2588     *
2589     */

2590    public String JavaDoc getContentAttributeAsPDFUrl(String JavaDoc contentBindningName, String JavaDoc attributeName)
2591    {
2592        String JavaDoc pdfUrl = "";
2593        
2594        try
2595        {
2596            String JavaDoc template = getParsedContentAttribute(contentBindningName, attributeName, true);
2597            String JavaDoc uniqueId = siteNodeId + "_" + attributeName + "_" + contentBindningName + template.hashCode();
2598            String JavaDoc fileName = uniqueId + ".pdf";
2599
2600            int i = 0;
2601            String JavaDoc filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
2602            while(filePath != null)
2603            {
2604                File JavaDoc pdfFile = new File JavaDoc(filePath + java.io.File.separator + fileName);
2605                if(!pdfFile.exists())
2606                {
2607                    logger.info("Creating a foprenderer");
2608                    FOPHelper fop = new FOPHelper();
2609                    fop.generatePDF(template, pdfFile);
2610                }
2611                i++;
2612                filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
2613            }
2614            
2615            /*
2616            String filePath = CmsPropertyHandler.getDigitalAssetPath();
2617            File pdfFile = new File(filePath + java.io.File.separator + fileName);
2618            if(!pdfFile.exists())
2619            {
2620                logger.info("Creating a foprenderer");
2621                FOPHelper fop = new FOPHelper();
2622                fop.generatePDF(template, pdfFile);
2623            }
2624            */

2625            SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId);
2626            String JavaDoc dnsName = CmsPropertyHandler.getWebServerAddress();
2627            if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
2628                dnsName = siteNode.getRepository().getDnsName();
2629
2630            //pdfUrl = dnsName + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + fileName;
2631
pdfUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext);
2632        }
2633        catch(Exception JavaDoc e)
2634        {
2635            logger.error("An error occurred trying to get ContentAttribute As PDFUrl:" + e.getMessage(), e);
2636        }
2637        
2638        return pdfUrl;
2639    }
2640    
2641    
2642    /**
2643     * This method uses the content-attribute to generate a pdf-file.
2644     * The content-attribute is parsed before it is sent to the renderer, and the
2645     * resulting string must follow the XSL-FO specification.
2646     *
2647     * The method checks if a previous file exists that has the same attributes as the wanted one
2648     * and if so - we don't generate it again.
2649     *
2650     */

2651    public String JavaDoc getContentAttributeAsPDFUrl(Integer JavaDoc contentId, String JavaDoc attributeName)
2652    {
2653        String JavaDoc pdfUrl = "";
2654        
2655        try
2656        {
2657            String JavaDoc template = getParsedContentAttribute(contentId, attributeName, true);
2658            String JavaDoc uniqueId = contentId + "_" + attributeName + template.hashCode();
2659            String JavaDoc fileName = uniqueId + ".pdf";
2660            
2661            int i = 0;
2662            String JavaDoc filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
2663            while(filePath != null)
2664            {
2665                File JavaDoc pdfFile = new File JavaDoc(filePath + java.io.File.separator + fileName);
2666                if(!pdfFile.exists())
2667                {
2668                    logger.info("Creating a foprenderer");
2669                    FOPHelper fop = new FOPHelper();
2670                    fop.generatePDF(template, pdfFile);
2671                }
2672                i++;
2673                filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
2674            }
2675            
2676            /*
2677            String filePath = CmsPropertyHandler.getDigitalAssetPath();
2678            File pdfFile = new File(filePath + java.io.File.separator + fileName);
2679            if(!pdfFile.exists())
2680            {
2681                logger.info("Creating a foprenderer");
2682                FOPHelper fop = new FOPHelper();
2683                fop.generatePDF(template, pdfFile);
2684            }
2685            */

2686            
2687            SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId);
2688            String JavaDoc dnsName = CmsPropertyHandler.getWebServerAddress();
2689            if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
2690                dnsName = siteNode.getRepository().getDnsName();
2691
2692            //pdfUrl = dnsName + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + fileName;
2693
pdfUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext);
2694        }
2695        catch(Exception JavaDoc e)
2696        {
2697            logger.error("An error occurred trying to get ContentAttribute As PDFUrl:" + e.getMessage(), e);
2698        }
2699        
2700        return pdfUrl;
2701    }
2702    
2703    /**
2704     * This method deliveres a String with the content-attribute asked for generated as a gif-file.
2705     * That is - the text is printed as an image. You can specify a number of things to control the
2706     * generation. Just experiment and the names are pretty much self explainatory.
2707     * The method checks if a previous file exists that has the same attributes as the wanted one
2708     * and if so - we don't generate it again.
2709     *
2710     * TODO: consider implement a more general getTextAsImageUrl so we dont need a zillion different variants
2711     * for different ways to access the contentAttribute. (we need to calculate a unique string from
2712     * the text and all the other stuff.)
2713     *
2714     */

2715    
2716    public String JavaDoc getContentAttributeAsImageUrl(String JavaDoc contentBindningName, String JavaDoc attributeName, int canvasWidth, int canvasHeight)
2717    {
2718        // Set some default values and pass on
2719
return getContentAttributeAsImageUrl(contentBindningName, attributeName, canvasWidth, canvasHeight, 5, 20, canvasWidth - 10, canvasHeight - 10, "Verdana", Font.BOLD, 28, Color.black, Color.white);
2720    }
2721
2722    public String JavaDoc getContentAttributeAsImageUrl(String JavaDoc contentBindningName,String JavaDoc attributeName,int canvasWidth,
2723                                                    int canvasHeight,int textStartPosX,int textStartPosY,int textWidth,
2724                                                    int textHeight,String JavaDoc fontName,int fontStyle,
2725                                                    int fontSize,String JavaDoc foregroundColor,String JavaDoc backgroundColor)
2726    {
2727        // Using contentBindingName: Convert color parameters and pass on
2728
return getContentAttributeAsImageUrl( contentBindningName,attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,
2729                                                new Color JavaDoc(getMathHelper().hexToDecimal(foregroundColor)),
2730                                                new Color JavaDoc(getMathHelper().hexToDecimal(backgroundColor)));
2731        
2732    }
2733
2734    public String JavaDoc getContentAttributeAsImageUrl(String JavaDoc contentBindningName,String JavaDoc attributeName,int canvasWidth,
2735                                                        int canvasHeight,int textStartPosX,int textStartPosY,int textWidth,
2736                                                        int textHeight,String JavaDoc fontName,int fontStyle,
2737                                                        int fontSize,String JavaDoc foregroundColor,String JavaDoc backgroundColor, String JavaDoc backgroundImageUrl)
2738    {
2739        // Using contentBindingName: Convert color parameters and pass on
2740
return getContentAttributeAsImageUrl( contentBindningName,attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,
2741                                                new Color JavaDoc(getMathHelper().hexToDecimal(foregroundColor)),
2742                                                new Color JavaDoc(getMathHelper().hexToDecimal(backgroundColor)));
2743    
2744    }
2745    
2746    public String JavaDoc getContentAttributeAsImageUrl(Integer JavaDoc contentId,String JavaDoc attributeName,int canvasWidth,
2747                                                    int canvasHeight,int textStartPosX,int textStartPosY,
2748                                                    int textWidth,int textHeight,String JavaDoc fontName,int fontStyle,
2749                                                    int fontSize,String JavaDoc foregroundColor,String JavaDoc backgroundColor)
2750    {
2751        // Using contentId: Convert color parameters and pass on
2752
return getContentAttributeAsImageUrl(contentId,attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,
2753                                                new Color JavaDoc(getMathHelper().hexToDecimal(foregroundColor)),
2754                                                new Color JavaDoc(getMathHelper().hexToDecimal(backgroundColor)));
2755    }
2756
2757    public String JavaDoc getContentAttributeAsImageUrl(String JavaDoc contentBindningName,String JavaDoc attributeName,int canvasWidth,int canvasHeight,int textStartPosX,int textStartPosY,int textWidth,int textHeight,String JavaDoc fontName,int fontStyle,int fontSize,Color JavaDoc foregroundColor, Color JavaDoc backgroundColor)
2758    {
2759        // Get the contentId from the contentBindingName and pass on
2760
String JavaDoc assetUrl = "";
2761        try
2762        {
2763            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
2764            if(contentVO != null)
2765                assetUrl = getContentAttributeAsImageUrl(contentVO.getContentId(),attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,foregroundColor,backgroundColor);
2766        }
2767        catch(Exception JavaDoc e)
2768        {
2769            logger.error("An error occurred trying to get ContentAttribute As ImageUrl:" + e.getMessage(), e);
2770        }
2771        
2772        return assetUrl;
2773    }
2774    
2775    public String JavaDoc getContentAttributeAsImageUrl(String JavaDoc contentBindningName, String JavaDoc attributeName, int canvasWidth, int canvasHeight, int textStartPosX, int textStartPosY, int textWidth, int textHeight, String JavaDoc fontName, int fontStyle, int fontSize, Color JavaDoc foregroundColor, Color JavaDoc backgroundColor, String JavaDoc backgroundImageUrl)
2776    {
2777        // Get the contentId from the contentBindingName and pass on
2778
String JavaDoc assetUrl = "";
2779        try
2780        {
2781            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
2782            if(contentVO != null)
2783                assetUrl = getContentAttributeAsImageUrl(contentVO.getContentId(),attributeName,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,foregroundColor,backgroundColor, backgroundImageUrl);
2784        }
2785        catch(Exception JavaDoc e)
2786        {
2787            logger.error("An error occurred trying to get ContentAttribute As ImageUrl:" + e.getMessage(), e);
2788        }
2789    
2790        return assetUrl;
2791    }
2792    
2793
2794    public String JavaDoc getContentAttributeAsImageUrl(Integer JavaDoc contentId,String JavaDoc attributeName,int canvasWidth,
2795                                                    int canvasHeight,int textStartPosX,int textStartPosY,
2796                                                    int textWidth,int textHeight,String JavaDoc fontName,
2797                                                    int fontStyle,int fontSize,
2798                                                    Color JavaDoc foregroundColor,Color JavaDoc backgroundColor)
2799    {
2800        return getContentAttributeAsImageUrl(contentId, attributeName, canvasWidth, canvasHeight, textStartPosX, textStartPosY, textWidth, textHeight, fontName, fontStyle, fontSize, foregroundColor, backgroundColor, null);
2801    }
2802
2803
2804    /**
2805     * Renders a text from values configured in a content, iterates over the
2806     * contenttype defenition names and look for font properties.
2807     * @param contentId a content id containing attributes to tell the image
2808     * renderer how to look.
2809     * @param text the text to render
2810     * @param renderAttributes render attributes in a map to override the
2811     * content settings
2812     * @return the asseturl or empty string if something is wrong or text is null or empty
2813     * @author Per Jonsson per.jonsson@it-huset.se
2814     */

2815    public String JavaDoc getRenderedTextUrl( Integer JavaDoc contentId, String JavaDoc text, Map JavaDoc renderAttributes )
2816    {
2817        String JavaDoc assetUrl = "";
2818        if ( text == null || text.length() == 0 )
2819        {
2820            logger.warn("Could not render text with a null or 0 lenght value on sitenode: " + this.getSiteNodeId() + ", contentId = " + contentId );
2821            return assetUrl;
2822        }
2823        try
2824        {
2825            ContentDeliveryController cdc = ContentDeliveryController.getContentDeliveryController();
2826            ContentTypeDefinitionController ctdc = ContentTypeDefinitionController.getController();
2827
2828            ContentVersionVO contentVersionVO = cdc.getContentVersionVO(getDatabase(), this.siteNodeId, contentId,this.languageId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal );
2829            
2830            Integer JavaDoc contentTypeDefinitionId = cdc.getContentVO(contentId, getDatabase() ).getContentTypeDefinitionId();
2831          
2832            ContentTypeDefinitionVO contentTypeDefinitionVO = ctdc.getContentTypeDefinitionVOWithId( contentTypeDefinitionId );
2833            Iterator JavaDoc attrIterator = ctdc.getContentTypeAttributes(contentTypeDefinitionVO.getSchemaValue() ).iterator();
2834            
2835            String JavaDoc aText = text.replaceAll( "[^\\w]", "" );
2836            aText = aText.substring( 0, ( aText.length() < 8 ? aText.length() : 8 ) ).toLowerCase();
2837            StringBuffer JavaDoc uniqueId = new StringBuffer JavaDoc( aText );
2838            uniqueId.append( "_" + contentVersionVO.getId() );
2839            uniqueId.append( "_" + Math.abs( text.hashCode() ));
2840            uniqueId.append( "_" + Math.abs(contentVersionVO.getVersionValue().hashCode() ) );
2841            uniqueId.append( "_" + Math.abs(contentTypeDefinitionVO.getSchemaValue().hashCode() ) );
2842            uniqueId.append( "_" + ( renderAttributes != null ? Math.abs( renderAttributes.hashCode() ) : 4711 ) );
2843
2844            AdvancedImageRenderer imageRenderer = new AdvancedImageRenderer();
2845            // set up the renderer
2846
while ( attrIterator.hasNext() )
2847            {
2848                ContentTypeAttribute contentTypeAttribute = (ContentTypeAttribute)(attrIterator.next());
2849                String JavaDoc attributeName = contentTypeAttribute.getName();
2850                if ( imageRenderer.hasAttribute( attributeName ) )
2851                {
2852                    String JavaDoc attribute = cdc.getContentAttribute(getDatabase(), contentVersionVO, attributeName, false );
2853                    imageRenderer.setAttribute( attributeName.toLowerCase(), attribute );
2854                }
2855            }
2856            // render the image
2857
imageRenderer.renderImage( text, renderAttributes );
2858            
2859            String JavaDoc fileName = uniqueId + "." + imageRenderer.getImageFormatName(); // default is png
2860
// write the result
2861
assetUrl = writeRenderedImage( imageRenderer, fileName );
2862        }
2863        catch ( Exception JavaDoc e )
2864        {
2865            logger.error( "An error occurred trying to getRenderedTextUrl(), text = " + text + ", on siteNodeId = " + this.siteNodeId + " :" + e.getMessage(), e );
2866        }
2867
2868        return assetUrl;
2869    }
2870
2871    /**
2872     * Renders a text from configuration stored in the propertyfile or in the
2873     * map.
2874     * @param text the text to render
2875     * @param renderAttributes render attributes in a map to override the
2876     * default or propertyfile settings
2877     * @return the asseturl or empty string if something is wrong or text is null or empty
2878     * @author Per Jonsson - per.jonsson@it-huset.se
2879     */

2880    public String JavaDoc getRenderedTextUrl( String JavaDoc text, Map JavaDoc renderAttributes )
2881    {
2882        String JavaDoc assetUrl = "";
2883        if ( text == null || text.length() == 0 )
2884        {
2885            logger.warn("Could not render text with a null or 0 lenght value on sitenode: " + this.getSiteNodeId() );
2886            return assetUrl;
2887        }
2888        try
2889        {
2890            String JavaDoc aText = text.replaceAll( "[^\\w]", "" );
2891            aText = aText.substring( 0, ( aText.length() < 12 ? aText.length() : 11 ) ).toLowerCase();
2892            StringBuffer JavaDoc uniqueId = new StringBuffer JavaDoc( aText );
2893            uniqueId.append( "_" + Math.abs( text.hashCode() ) );
2894            uniqueId.append( "_" + ( renderAttributes != null ? Math.abs( renderAttributes.hashCode() ) : 4711 ) );
2895
2896            AdvancedImageRenderer imageRenderer = new AdvancedImageRenderer();
2897            // render the image
2898
imageRenderer.renderImage( text, renderAttributes );
2899
2900            String JavaDoc fileName = uniqueId + "." + imageRenderer.getImageFormatName(); // default is png
2901

2902            // write the result
2903
assetUrl = writeRenderedImage( imageRenderer, fileName );
2904        }
2905        catch ( Exception JavaDoc e )
2906        {
2907            logger.error( "An error occurred trying to getRenderedTextUrl(), text = " + text + ", on siteNodeId = " + this.siteNodeId + " :" + e.getMessage(), e );
2908        }
2909
2910        return assetUrl;
2911    }
2912
2913
2914    /**
2915     * Writes a rendered imagefile,
2916     * @param imageRenderer a valid configured
2917     * @param fileName the filename of the image
2918     * @return an asseturl of the image
2919     * @throws SystemException if something goes wrong
2920     * @author Per Jonsson - per.jonsson@it-huset.se
2921     */

2922    private String JavaDoc writeRenderedImage( AdvancedImageRenderer imageRenderer, String JavaDoc fileName ) throws SystemException
2923    {
2924        // write the result
2925
int i = 0;
2926        String JavaDoc filePath = CmsPropertyHandler.getProperty( "digitalAssetPath." + i );
2927        while ( filePath != null )
2928        {
2929            File JavaDoc imageFile = new File JavaDoc( filePath, fileName );
2930            if ( !imageFile.exists() )
2931            {
2932                imageRenderer.writeImage( imageFile );
2933            }
2934            i++;
2935            filePath = CmsPropertyHandler.getProperty( "digitalAssetPath." + i );
2936        }
2937
2938        SiteNode siteNode = this.nodeDeliveryController.getSiteNode( getDatabase(), this.siteNodeId );
2939        String JavaDoc dnsName = CmsPropertyHandler.getWebServerAddress();
2940        if ( siteNode != null && siteNode.getRepository().getDnsName() != null
2941                && !siteNode.getRepository().getDnsName().equals( "" ) )
2942        {
2943            dnsName = siteNode.getRepository().getDnsName();
2944        }
2945
2946        return urlComposer.composeDigitalAssetUrl( dnsName, fileName, deliveryContext );
2947    }
2948    
2949    
2950    public String JavaDoc getContentAttributeAsImageUrl(Integer JavaDoc contentId,String JavaDoc attributeName,int canvasWidth,
2951                                                    int canvasHeight,int textStartPosX,int textStartPosY,
2952                                                    int textWidth,int textHeight,String JavaDoc fontName,
2953                                                    int fontStyle,int fontSize,
2954                                                    Color JavaDoc foregroundColor,Color JavaDoc backgroundColor, String JavaDoc backgroundImageUrl)
2955    {
2956        // This one actually does something.
2957
String JavaDoc assetUrl = "";
2958
2959        try
2960        {
2961            ContentVersionVO contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, this.languageId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
2962            
2963            String JavaDoc attribute = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVersionVO, attributeName, false);
2964            
2965            String JavaDoc uniqueId = contentVersionVO.getId() + "_" + attributeName + canvasWidth + canvasHeight + textStartPosX + textStartPosY + textWidth + textHeight + fontName.replaceAll(" ", "") + fontStyle + fontSize + foregroundColor.getRed() + foregroundColor.getGreen() + foregroundColor.getBlue() + backgroundColor.getRed() + backgroundColor.getGreen() + backgroundColor.getBlue();
2966            
2967            String JavaDoc fileName = uniqueId + ".png";
2968            
2969            int i = 0;
2970            String JavaDoc filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
2971            while(filePath != null)
2972            {
2973                File JavaDoc imageFile = new File JavaDoc(filePath + java.io.File.separator + fileName);
2974                if(!imageFile.exists())
2975                {
2976                    logger.info("Creating a imagerenderer");
2977                    ImageRenderer imageRenderer = new ImageRenderer();
2978                    imageRenderer.setCanvasWidth(canvasWidth);
2979                    imageRenderer.setCanvasHeight(canvasHeight);
2980                    imageRenderer.setTextStartPosX(textStartPosX);
2981                    imageRenderer.setTextStartPosY(textStartPosY);
2982                    imageRenderer.setTextWidth(textWidth);
2983                    imageRenderer.setTextHeight(textHeight);
2984                    imageRenderer.setFontName(fontName);
2985                    imageRenderer.setFontStyle(fontStyle);
2986                    imageRenderer.setFontSize(fontSize);
2987                    imageRenderer.setForeGroundColor(foregroundColor);
2988                    imageRenderer.setBackgroundColor(backgroundColor);
2989                    imageRenderer.setBackgroundImageUrl(backgroundImageUrl);
2990                    
2991                    logger.info("Created imageRenderer and printing to " + filePath + java.io.File.separator + fileName);
2992                    imageRenderer.generateGifImageFromText(filePath + java.io.File.separator + fileName, attribute, LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), this.languageId).getCharset());
2993                    logger.info("Rendered in getContentAttributeAsImageUrl");
2994                }
2995
2996                i++;
2997                filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
2998            }
2999            /*
3000            String filePath = CmsPropertyHandler.getDigitalAssetPath();
3001            File imageFile = new File(filePath + java.io.File.separator + fileName);
3002            if(!imageFile.exists())
3003            {
3004                logger.info("Creating a imagerenderer");
3005                ImageRenderer imageRenderer = new ImageRenderer();
3006                imageRenderer.setCanvasWidth(canvasWidth);
3007                imageRenderer.setCanvasHeight(canvasHeight);
3008                imageRenderer.setTextStartPosX(textStartPosX);
3009                imageRenderer.setTextStartPosY(textStartPosY);
3010                imageRenderer.setTextWidth(textWidth);
3011                imageRenderer.setTextHeight(textHeight);
3012                imageRenderer.setFontName(fontName);
3013                imageRenderer.setFontStyle(fontStyle);
3014                imageRenderer.setFontSize(fontSize);
3015                imageRenderer.setForeGroundColor(foregroundColor);
3016                imageRenderer.setBackgroundColor(backgroundColor);
3017                imageRenderer.setBackgroundImageUrl(backgroundImageUrl);
3018                
3019                logger.info("Created imageRenderer and printing to " + filePath + java.io.File.separator + fileName);
3020                imageRenderer.generateGifImageFromText(filePath + java.io.File.separator + fileName, attribute, LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), this.languageId).getCharset());
3021                logger.info("Rendered in getContentAttributeAsImageUrl");
3022            }
3023            */

3024            
3025            SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId);
3026            String JavaDoc dnsName = CmsPropertyHandler.getWebServerAddress();
3027            if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
3028                dnsName = siteNode.getRepository().getDnsName();
3029
3030            //assetUrl = dnsName + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + fileName;
3031
assetUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext);
3032        }
3033        catch(Exception JavaDoc e)
3034        {
3035            logger.error("An error occurred trying to get ContentAttribute As ImageUrl:" + e.getMessage(), e);
3036        }
3037                
3038        return assetUrl;
3039    }
3040
3041    /**
3042     * This method returns a list of elements/attributes based on the contentType sent in.
3043     */

3044    
3045    public List JavaDoc getContentAttributes(String JavaDoc schemaValue)
3046    {
3047        return ContentTypeDefinitionController.getController().getContentTypeAttributes(schemaValue);
3048    }
3049    
3050    /**
3051     * This method deliveres a String with the content-attribute asked for generated as a png-file.
3052     * That is - the text is printed as an image. You can specify a number of things to control the
3053     * generation. Just experiment and the names are pretty much self explainatory.
3054     * The method checks if a previous file exists that has the same attributes as the wanted one
3055     * and if so - we don't generate it again.
3056     */

3057    public String JavaDoc getStringAsImageUrl(String JavaDoc text,
3058                                           int canvasWidth,
3059                                           int canvasHeight,
3060                                           int textStartPosX,
3061                                           int textStartPosY,
3062                                           int textWidth,
3063                                           int textHeight,
3064                                           String JavaDoc fontName,
3065                                           int fontStyle,
3066                                           int fontSize,
3067                                           String JavaDoc foregroundColor,
3068                                           String JavaDoc backgroundColor)
3069        {
3070            return getStringAsImageUrl(text, canvasWidth, canvasHeight,textStartPosX, textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,
3071            new Color JavaDoc(getMathHelper().hexToDecimal(foregroundColor)),
3072            new Color JavaDoc(getMathHelper().hexToDecimal(backgroundColor)));
3073        }
3074    public String JavaDoc getStringAsImageUrl(String JavaDoc text,
3075               int canvasWidth,
3076               int canvasHeight,
3077               int textStartPosX,
3078               int textStartPosY,
3079               int textWidth,
3080               int textHeight,
3081               String JavaDoc fontName,
3082               int fontStyle,
3083               int fontSize,
3084               String JavaDoc foregroundColor,
3085               String JavaDoc backgroundColor, String JavaDoc backGroundImageUrl)
3086    {
3087        return getStringAsImageUrl(text, canvasWidth, canvasHeight,textStartPosX, textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,
3088        new Color JavaDoc(getMathHelper().hexToDecimal(foregroundColor)),
3089        new Color JavaDoc(getMathHelper().hexToDecimal(backgroundColor)), backGroundImageUrl);
3090    }
3091
3092    public String JavaDoc getStringAsImageUrl(String JavaDoc text,
3093               int canvasWidth,
3094               int canvasHeight,
3095               int textStartPosX,
3096               int textStartPosY,
3097               int textWidth,
3098               int textHeight,
3099               String JavaDoc fontName,
3100               int fontStyle,
3101               int fontSize,
3102               Color JavaDoc foregroundColor,
3103               Color JavaDoc backgroundColor)
3104    {
3105         return getStringAsImageUrl(text,canvasWidth,canvasHeight,textStartPosX,textStartPosY,textWidth,textHeight,fontName,fontStyle,fontSize,foregroundColor,backgroundColor,null);
3106    }
3107
3108    public String JavaDoc getStringAsImageUrl(String JavaDoc text,
3109                                       int canvasWidth,
3110                                       int canvasHeight,
3111                                       int textStartPosX,
3112                                       int textStartPosY,
3113                                       int textWidth,
3114                                       int textHeight,
3115                                       String JavaDoc fontName,
3116                                       int fontStyle,
3117                                       int fontSize,
3118                                       Color JavaDoc foregroundColor,
3119                                       Color JavaDoc backgroundColor, String JavaDoc backgroundImageUrl)
3120    {
3121        String JavaDoc assetUrl = "";
3122         
3123        try
3124        {
3125            String JavaDoc uniqueId = text.hashCode() + "_" + canvasWidth + canvasHeight + textStartPosX + textStartPosY + textWidth + textHeight + fontName.replaceAll(" ", "") + fontStyle + fontSize + foregroundColor.getRed() + foregroundColor.getGreen() + foregroundColor.getBlue() + backgroundColor.getRed() + backgroundColor.getGreen() + backgroundColor.getBlue();
3126            
3127            String JavaDoc fileName = uniqueId + ".png";
3128            
3129            int i = 0;
3130            String JavaDoc filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
3131            while(filePath != null)
3132            {
3133                File JavaDoc imageFile = new File JavaDoc(filePath + java.io.File.separator + fileName);
3134                if(!imageFile.exists())
3135                {
3136                    logger.info("Creating a imagerenderer");
3137                    ImageRenderer imageRenderer = new ImageRenderer();
3138                    imageRenderer.setCanvasWidth(canvasWidth);
3139                    imageRenderer.setCanvasHeight(canvasHeight);
3140                    imageRenderer.setTextStartPosX(textStartPosX);
3141                    imageRenderer.setTextStartPosY(textStartPosY);
3142                    imageRenderer.setTextWidth(textWidth);
3143                    imageRenderer.setTextHeight(textHeight);
3144                    imageRenderer.setFontName(fontName);
3145                    imageRenderer.setFontStyle(fontStyle);
3146                    imageRenderer.setFontSize(fontSize);
3147                    imageRenderer.setForeGroundColor(foregroundColor);
3148                    imageRenderer.setBackgroundColor(backgroundColor);
3149                    imageRenderer.setBackgroundImageUrl(backgroundImageUrl);
3150                    
3151                    logger.info("Created imageRenderer and printing to " + filePath + java.io.File.separator + fileName);
3152                    imageRenderer.generateGifImageFromText(filePath + java.io.File.separator + fileName, text, LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), this.languageId).getCharset());
3153                    logger.info("Rendered in getContentAttributeAsImageUrl");
3154                }
3155
3156                i++;
3157                filePath = CmsPropertyHandler.getProperty("digitalAssetPath." + i);
3158            }
3159            /*
3160            String filePath = CmsPropertyHandler.getDigitalAssetPath();
3161            File imageFile = new File(filePath + java.io.File.separator + fileName);
3162            if(!imageFile.exists())
3163            {
3164                logger.info("Creating a imagerenderer");
3165                ImageRenderer imageRenderer = new ImageRenderer();
3166                imageRenderer.setCanvasWidth(canvasWidth);
3167                imageRenderer.setCanvasHeight(canvasHeight);
3168                imageRenderer.setTextStartPosX(textStartPosX);
3169                imageRenderer.setTextStartPosY(textStartPosY);
3170                imageRenderer.setTextWidth(textWidth);
3171                imageRenderer.setTextHeight(textHeight);
3172                imageRenderer.setFontName(fontName);
3173                imageRenderer.setFontStyle(fontStyle);
3174                imageRenderer.setFontSize(fontSize);
3175                imageRenderer.setForeGroundColor(foregroundColor);
3176                imageRenderer.setBackgroundColor(backgroundColor);
3177                imageRenderer.setBackgroundImageUrl(backgroundImageUrl);
3178                
3179                logger.info("Created imageRenderer and printing to " + filePath + java.io.File.separator + fileName);
3180                imageRenderer.generateGifImageFromText(filePath + java.io.File.separator + fileName, text, LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), this.languageId).getCharset());
3181                logger.info("Rendered in getContentAttributeAsImageUrl");
3182            }
3183            */

3184            
3185            SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId);
3186            String JavaDoc dnsName = CmsPropertyHandler.getWebServerAddress();
3187            if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
3188                dnsName = siteNode.getRepository().getDnsName();
3189                
3190            //assetUrl = dnsName + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl() + "/" + fileName;
3191
assetUrl = urlComposer.composeDigitalAssetUrl(dnsName, fileName, deliveryContext);
3192        }
3193        catch(Exception JavaDoc e)
3194        {
3195            logger.error("An error occurred trying to render string as an image:" + e.getMessage(), e);
3196        }
3197                
3198        return assetUrl;
3199    }
3200
3201    
3202    /**
3203     * This method returns the base url for the digital assets.
3204     */

3205    
3206    public String JavaDoc getDigitalAssetBaseUrl() throws Exception JavaDoc
3207    {
3208        String JavaDoc url = getRepositoryBaseUrl() + "/" + CmsPropertyHandler.getDigitalAssetBaseUrl();
3209        
3210        return url;
3211    }
3212
3213    /**
3214     * This method returns the Id the digital assets.
3215     */

3216    
3217    public Integer JavaDoc getDigitalAssetId(Integer JavaDoc contentId, String JavaDoc assetKey) throws Exception JavaDoc
3218    {
3219        return ContentDeliveryController.getContentDeliveryController().getDigitalAssetId(getDatabase(), contentId, this.languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
3220    }
3221
3222    /**
3223     * This method returns the Id the digital assets.
3224     */

3225    
3226    public Integer JavaDoc getDigitalAssetId(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc assetKey) throws Exception JavaDoc
3227    {
3228        return ContentDeliveryController.getContentDeliveryController().getDigitalAssetId(getDatabase(), contentId, languageId, assetKey, this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal);
3229    }
3230
3231    /**
3232     * This method returns the base url for the digital assets.
3233     */

3234    
3235    public String JavaDoc getRepositoryBaseUrl() throws Exception JavaDoc
3236    {
3237        String JavaDoc url = "";
3238    
3239        String JavaDoc context = CmsPropertyHandler.getProperty(FilterConstants.CMS_PROPERTY_SERVLET_CONTEXT);
3240
3241        SiteNode siteNode = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId);
3242        String JavaDoc dnsName = CmsPropertyHandler.getWebServerAddress();
3243        if(siteNode != null && siteNode.getRepository().getDnsName() != null && !siteNode.getRepository().getDnsName().equals(""))
3244        {
3245            dnsName = siteNode.getRepository().getDnsName();
3246
3247            String JavaDoc useDNSNameInUrls = CmsPropertyHandler.getUseDNSNameInURI();
3248     
3249            if(!useDNSNameInUrls.equalsIgnoreCase("false"))
3250            {
3251                String JavaDoc operatingMode = CmsPropertyHandler.getOperatingMode();
3252                String JavaDoc keyword = "";
3253                if(operatingMode.equalsIgnoreCase("0"))
3254                    keyword = "working=";
3255                else if(operatingMode.equalsIgnoreCase("2"))
3256                    keyword = "preview=";
3257                if(operatingMode.equalsIgnoreCase("3"))
3258                    keyword = "live=";
3259                
3260                if(dnsName != null)
3261                {
3262                    int startIndex = dnsName.indexOf(keyword);
3263                    if(startIndex != -1)
3264                    {
3265                        int endIndex = dnsName.indexOf(",", startIndex);
3266                        if(endIndex > -1)
3267                            dnsName = dnsName.substring(startIndex, endIndex);
3268                        else
3269                            dnsName = dnsName.substring(startIndex);
3270                        
3271                        dnsName = dnsName.split("=")[1];
3272                    }
3273                    else
3274                    {
3275                        int endIndex = dnsName.indexOf(",");
3276                        if(endIndex > -1)
3277                            dnsName = dnsName.substring(0, endIndex);
3278                        else
3279                            dnsName = dnsName.substring(0);
3280                        
3281                    }
3282                }
3283                    
3284                dnsName = dnsName + context;
3285            }
3286            else
3287            {
3288                dnsName = context;
3289            }
3290        }
3291        
3292        url = dnsName;
3293        
3294        return url;
3295    }
3296
3297    /**
3298     * This method returns the root node for the current repository.
3299     */

3300    
3301    public SiteNodeVO getRepositoryRootSiteNode() throws Exception JavaDoc
3302    {
3303        Integer JavaDoc repositoryId = this.getSiteNode(this.siteNodeId).getRepositoryId();
3304        SiteNodeVO siteNodeVO = getRepositoryRootSiteNode(repositoryId);
3305
3306        return siteNodeVO;
3307    }
3308
3309    /**
3310     * This method returns the root node for the current repository.
3311     */

3312    
3313    public SiteNodeVO getRepositoryRootSiteNode(Integer JavaDoc repositoryId) throws Exception JavaDoc
3314    {
3315        SiteNodeVO siteNodeVO = this.nodeDeliveryController.getRootSiteNode(getDatabase(), repositoryId);
3316
3317        return siteNodeVO;
3318    }
3319
3320    /**
3321     * This method returns the parent repositoryId if any for the given repository.
3322     */

3323    
3324    public Integer JavaDoc getParentRepositoryId(Integer JavaDoc repositoryId)
3325    {
3326        String JavaDoc parentRepository = RepositoryDeliveryController.getRepositoryDeliveryController().getPropertyValue(repositoryId, "parentRepository");
3327        if(parentRepository != null && !parentRepository.equalsIgnoreCase(""))
3328            return new Integer JavaDoc(parentRepository);
3329        else
3330            return null;
3331    }
3332
3333    /**
3334     * This method returns the parent repositoryId if any for the given repository.
3335     */

3336    
3337    public Integer JavaDoc getParentRepositoryId()
3338    {
3339        Integer JavaDoc repositoryId = this.getSiteNode(this.siteNodeId).getRepositoryId();
3340        return getParentRepositoryId(repositoryId);
3341    }
3342
3343    /**
3344     * This method deliveres a String with the URL to the page asked for.
3345     * As the siteNode can have multiple bindings the method requires a bindingName
3346     * which refers to the AvailableServiceBinding.name-attribute.
3347     */

3348     
3349    public String JavaDoc getPageUrl(String JavaDoc structureBindningName)
3350    {
3351        String JavaDoc pageUrl = "";
3352        
3353        try
3354        {
3355            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName);
3356            if(siteNodeVO != null)
3357                pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext);
3358        }
3359        catch(Exception JavaDoc e)
3360        {
3361            logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e);
3362        }
3363                
3364        return pageUrl;
3365    }
3366
3367
3368    /**
3369     * This method just gets a new URL but with the given contentId in it.
3370     */

3371     
3372    public String JavaDoc getPageUrl(WebPage webpage, Integer JavaDoc contentId)
3373    {
3374        String JavaDoc pageUrl = "";
3375        
3376        try
3377        {
3378            pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), webpage.getSiteNodeId(), webpage.getLanguageId(), contentId, this.deliveryContext);
3379        }
3380        catch(Exception JavaDoc e)
3381        {
3382            logger.error("An error occurred trying to get the transformed page url " + contentId + ":" + e.getMessage(), e);
3383        }
3384                
3385        return pageUrl;
3386    }
3387
3388
3389    /**
3390     * This method deliveres a String with the URL to the page asked for.
3391     * As the siteNode can have multiple bindings the method requires a bindingName
3392     * which refers to the AvailableServiceBinding.name-attribute.
3393     */

3394     
3395    public String JavaDoc getPageBaseUrl(String JavaDoc structureBindningName)
3396    {
3397        String JavaDoc pageUrl = "";
3398        
3399        try
3400        {
3401            pageUrl = this.nodeDeliveryController.getPageBaseUrl(getDatabase());
3402        }
3403        catch(Exception JavaDoc e)
3404        {
3405            logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e);
3406        }
3407                
3408        return pageUrl;
3409    }
3410
3411    /**
3412     * This method deliveres a String with the URL to the page asked for.
3413     * As the siteNode can have multiple bindings the method requires a bindingName
3414     * which refers to the AvailableServiceBinding.name-attribute.
3415     */

3416     
3417    public String JavaDoc getPageBaseUrl()
3418    {
3419        String JavaDoc pageUrl = "";
3420        
3421        try
3422        {
3423            pageUrl = this.nodeDeliveryController.getPageBaseUrl(getDatabase());
3424        }
3425        catch(Exception JavaDoc e)
3426        {
3427            logger.error("An error occurred trying to get page url the current url:" + e.getMessage(), e);
3428        }
3429                
3430        return pageUrl;
3431    }
3432
3433    /**
3434     * Getter for the current siteNode
3435     */

3436    
3437    public SiteNodeVO getSiteNode()
3438    {
3439        SiteNodeVO siteNodeVO = null;
3440
3441        try
3442        {
3443            siteNodeVO = this.nodeDeliveryController.getSiteNode(getDatabase(), this.siteNodeId).getValueObject();
3444        }
3445        catch(Exception JavaDoc e)
3446        {
3447            logger.warn("An error occurred trying to get the current content:" + e.getMessage(), e);
3448        }
3449
3450        return siteNodeVO;
3451    }
3452
3453
3454    /**
3455     * This method fetches the given siteNode
3456     */

3457    
3458    public SiteNodeVO getSiteNode(Integer JavaDoc siteNodeId)
3459    {
3460        SiteNodeVO siteNodeVO = null;
3461
3462        try
3463        {
3464            siteNodeVO = this.nodeDeliveryController.getSiteNode(getDatabase(), siteNodeId).getValueObject();
3465        }
3466        catch(Exception JavaDoc e)
3467        {
3468            logger.warn("An error occurred trying to get the siteNode with id " + siteNodeId + ":" + e.getMessage(), e);
3469        }
3470
3471        return siteNodeVO;
3472    }
3473
3474    /**
3475     * Getter for the siteNodeId on a specific bound page
3476     */

3477    
3478    public Integer JavaDoc getSiteNodeId(String JavaDoc structureBindningName)
3479    {
3480        Integer JavaDoc siteNodeId = null;
3481        
3482        try
3483        {
3484            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName);
3485            siteNodeId = siteNodeVO.getSiteNodeId();
3486        }
3487        catch(Exception JavaDoc e)
3488        {
3489            logger.error("An error occurred trying to get siteNodeId for structureBindningName " + structureBindningName + ":" + e.getMessage(), e);
3490        }
3491                
3492        return siteNodeId;
3493    }
3494
3495
3496    /**
3497     * Getter for bound contentId for a binding
3498     */

3499    
3500    public Integer JavaDoc getContentId(String JavaDoc contentBindningName)
3501    {
3502        Integer JavaDoc contentId = null;
3503        
3504        try
3505        {
3506            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
3507            if(contentVO != null)
3508            {
3509                contentId = contentVO.getId();
3510            }
3511        }
3512        catch(Exception JavaDoc e)
3513        {
3514            logger.error("An error occurred trying to get contentId for contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
3515        }
3516                
3517        return contentId;
3518    }
3519    
3520    /**
3521     * This method gets the meta information of the current sitenode.
3522     */

3523    
3524    public Integer JavaDoc getMetaInformationContentId()
3525    {
3526        return this.getContentId(META_INFO_BINDING_NAME);
3527    }
3528    
3529    /**
3530     * This method gets the meta information of a particular sitenode.
3531     */

3532    
3533    public Integer JavaDoc getMetaInformationContentId(Integer JavaDoc siteNodeId)
3534    {
3535        return this.getContentId(siteNodeId, META_INFO_BINDING_NAME);
3536    }
3537    
3538    /**
3539     * This method gets the children of a content.
3540     */

3541    
3542    public Collection JavaDoc getChildContents(Integer JavaDoc contentId, boolean includeFolders)
3543    {
3544        List JavaDoc childContents = null;
3545        
3546        try
3547        {
3548            childContents = ContentDeliveryController.getContentDeliveryController().getChildContents(getDatabase(), this.getPrincipal(), contentId, this.languageId, USE_LANGUAGE_FALLBACK, includeFolders, this.deliveryContext);
3549        }
3550        catch(Exception JavaDoc e)
3551        {
3552            logger.error("An error occurred trying to get childContents for contentId " + contentId + ":" + e.getMessage(), e);
3553        }
3554                
3555        return childContents;
3556    }
3557
3558
3559    /**
3560     * Getter for bound contentId for a binding on a special siteNode
3561     */

3562    
3563    public Integer JavaDoc getContentId(Integer JavaDoc siteNodeId, String JavaDoc contentBindningName)
3564    {
3565        Integer JavaDoc contentId = null;
3566        
3567        try
3568        {
3569            ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
3570            if(contentVO != null)
3571            {
3572                contentId = contentVO.getId();
3573            }
3574        }
3575        catch(Exception JavaDoc e)
3576        {
3577            logger.warn("An error occurred trying to get contentId for contentBindningName " + contentBindningName + ":" + e.getMessage(), e);
3578        }
3579                
3580        return contentId;
3581    }
3582
3583    /**
3584     * This method gets the content related to a category
3585     */

3586    public List JavaDoc getContentVersionsByCategory(Integer JavaDoc categoryId, String JavaDoc attributeName)
3587    {
3588        try
3589        {
3590            return ContentDeliveryController.getContentDeliveryController().findContentVersionVOsForCategory(getDatabase(), categoryId, attributeName, getPrincipal(), siteNodeId, languageId, USE_LANGUAGE_FALLBACK, this.deliveryContext);
3591        }
3592        catch(Exception JavaDoc e)
3593        {
3594            logger.error("An error occurred trying to get Content for categoryId " + categoryId + ":" + e.getMessage(), e);
3595        }
3596
3597        return Collections.EMPTY_LIST;
3598    }
3599
3600    /**
3601     * This method searches for all contents matching
3602     */

3603    
3604    public List JavaDoc getMatchingContents(String JavaDoc contentTypeDefinitionNamesString, String JavaDoc categoryConditionString, boolean useLanguageFallback)
3605    {
3606        try
3607        {
3608            List JavaDoc contentTypeDefinitionVOList = new ArrayList JavaDoc();
3609            String JavaDoc[] contentTypeDefinitionNames = contentTypeDefinitionNamesString.split(",");
3610            for(int i=0; i<contentTypeDefinitionNames.length; i++)
3611            {
3612                ContentTypeDefinitionVO contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName(contentTypeDefinitionNames[i], getDatabase());
3613                contentTypeDefinitionVOList.add(contentTypeDefinitionVO);
3614            }
3615
3616            final CategoryConditions categoryConditions = CategoryConditions.parse(categoryConditionString);
3617            final Set JavaDoc set = ExtendedSearchController.getController().search(getOperatingMode(), contentTypeDefinitionVOList, this.getLanguage(this.getLanguageId()), categoryConditions, getDatabase());
3618            
3619            final List JavaDoc result = new ArrayList JavaDoc();
3620            for(Iterator JavaDoc i = set.iterator(); i.hasNext(); )
3621            {
3622                final Content content = (Content) i.next();
3623                //System.out.println("content: " + content.getName());
3624
if(ContentDeliveryController.getContentDeliveryController().isValidContent(this.getDatabase(), content.getId(), this.languageId, USE_LANGUAGE_FALLBACK, true, getPrincipal(), this.deliveryContext))
3625                    result.add(content.getValueObject());
3626            }
3627            return result;
3628        }
3629        catch(Exception JavaDoc e)
3630        {
3631            logger.warn("An error occurred trying to get Matching Contents for contentTypeDefinitionNamesString: " + contentTypeDefinitionNamesString + ":" + e.getMessage(), e);
3632        }
3633
3634        return Collections.EMPTY_LIST;
3635    }
3636
3637    /**
3638     * This method returns which mode the delivery-engine is running in.
3639     * The mode is important to be able to show working, preview and published data separate.
3640     */

3641    
3642    public Integer JavaDoc getOperatingMode()
3643    {
3644        Integer JavaDoc operatingMode = new Integer JavaDoc(0); //Default is working
3645
try
3646        {
3647            operatingMode = new Integer JavaDoc(CmsPropertyHandler.getOperatingMode());
3648            //logger.info("Operating mode is:" + operatingMode);
3649
}
3650        catch(Exception JavaDoc e)
3651        {
3652            logger.warn("We could not get the operating mode from the propertyFile:" + e.getMessage(), e);
3653        }
3654        return operatingMode;
3655    }
3656    
3657    /**
3658     * This method deliveres a String with the URL to the page asked for.
3659     * As the siteNode can have multiple bindings the method requires a bindingName
3660     * which refers to the AvailableServiceBinding.name-attribute. This method also allows the user
3661     * to specify that the content is important. This method is mostly used for master/detail-pages.
3662     */

3663     
3664    public String JavaDoc getPageUrl(String JavaDoc structureBindningName, Integer JavaDoc contentId)
3665    {
3666        String JavaDoc pageUrl = "";
3667        
3668        try
3669        {
3670            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName);
3671            pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, contentId, this.deliveryContext);
3672        }
3673        catch(Exception JavaDoc e)
3674        {
3675            logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e);
3676        }
3677                
3678        return pageUrl;
3679    }
3680
3681
3682    /**
3683     * This method deliveres a String with the URL to the page asked for.
3684     * As the siteNode can have multiple bindings the method requires a bindingName and also allows the user to specify a
3685     * special siteNode in an ordered collection.
3686     * which refers to the AvailableServiceBinding.name-attribute.
3687     */

3688     
3689    public String JavaDoc getPageUrlOnPosition(String JavaDoc structureBindningName, int position)
3690    {
3691        String JavaDoc pageUrl = "";
3692        
3693        try
3694        {
3695            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName, position);
3696            pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext);
3697        }
3698        catch(Exception JavaDoc e)
3699        {
3700            logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e);
3701        }
3702                
3703        return pageUrl;
3704    }
3705
3706
3707    /**
3708     * This method deliveres a String with the URL to the page asked for.
3709     * As the siteNode can have multiple bindings the method requires a bindingName and also allows the user to specify a
3710     * special siteNode in an ordered collection.
3711     * which refers to the AvailableServiceBinding.name-attribute. This method also allows the user
3712     * to specify that the content is important. This method is mostly used for master/detail-pages.
3713     */

3714     
3715    public String JavaDoc getPageUrl(String JavaDoc structureBindningName, int position, Integer JavaDoc contentId)
3716    {
3717        String JavaDoc pageUrl = "";
3718        
3719        try
3720        {
3721            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName, position);
3722            pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, contentId, this.deliveryContext);
3723        }
3724        catch(Exception JavaDoc e)
3725        {
3726            logger.error("An error occurred trying to get page url for structureBindningName " + structureBindningName + ":" + e.getMessage(), e);
3727        }
3728                
3729        return pageUrl;
3730    }
3731
3732
3733    /**
3734     * This method deliveres a new url pointing to the same address as now but in the language
3735     * corresponding to the code sent in.
3736     */

3737     
3738    public String JavaDoc getCurrentPageUrl()
3739    {
3740        String JavaDoc pageUrl = "";
3741        
3742        try
3743        {
3744            pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, this.contentId, this.deliveryContext);
3745        }
3746        catch(Exception JavaDoc e)
3747        {
3748            logger.error("An error occurred trying to get current page url:" + e.getMessage(), e);
3749        }
3750                
3751        return pageUrl;
3752    }
3753
3754    /**
3755     * This method returns the exact full url from the original request - not modified
3756     * @return
3757     */

3758    
3759    public String JavaDoc getOriginalFullURL()
3760    {
3761        String JavaDoc originalRequestURL = this.getHttpServletRequest().getParameter("originalRequestURL");
3762        if(originalRequestURL == null || originalRequestURL.length() == 0)
3763            originalRequestURL = this.getHttpServletRequest().getRequestURL().toString();
3764
3765        String JavaDoc originalQueryString = this.getHttpServletRequest().getParameter("originalQueryString");
3766        if(originalQueryString == null || originalQueryString.length() == 0)
3767            originalQueryString = this.getHttpServletRequest().getQueryString();
3768
3769        return originalRequestURL + "?" + originalQueryString;
3770    }
3771
3772    /**
3773     * This method deliveres a new url pointing to the same address as now but with new parameters.
3774     */

3775     
3776    public String JavaDoc getPageUrl(Integer JavaDoc siteNodeId, Integer JavaDoc languageId, Integer JavaDoc contentId)
3777    {
3778        String JavaDoc pageUrl = "";
3779        
3780        try
3781        {
3782            pageUrl = this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeId, languageId, contentId, this.deliveryContext);
3783        }
3784        catch(Exception JavaDoc e)
3785        {
3786            logger.error("An error occurred trying to get current page url:" + e.getMessage(), e);
3787        }
3788                
3789        return pageUrl;
3790    }
3791
3792    /**
3793     * This method calls an page and stores it as an digitalAsset - that way one can avoid having to
3794     * serve javascript-files and css-files through InfoGlue. Not suitable for use if you have very dynamic
3795     * css:es or scripts which includes logic depending on user info etc.. mostly usable if you have a static css
3796     * or controls it on the pageCache parameters.
3797     */

3798     
3799    public String JavaDoc getPageAsDigitalAssetUrl(Integer JavaDoc siteNodeId, Integer JavaDoc languageId, Integer JavaDoc contentId, String JavaDoc fileSuffix)
3800    {
3801        String JavaDoc pageDigitalAssetUrl = "";
3802        
3803        try
3804        {
3805            pageDigitalAssetUrl = this.nodeDeliveryController.getPageAsDigitalAssetUrl(getDatabase(), this.getPrincipal(), siteNodeId, languageId, contentId, this.deliveryContext, fileSuffix);
3806        }
3807        catch(Exception JavaDoc e)
3808        {
3809            logger.error("An error occurred trying to get current page digitalAsset url:" + e.getMessage(), e);
3810        }
3811                
3812        return pageDigitalAssetUrl;
3813    }
3814
3815    /**
3816     * This method constructs a string representing the path to the page with respect to where in the
3817     * structure the page is. It also takes the page title into consideration.
3818     */

3819     
3820    public String JavaDoc getCurrentPagePath()
3821    {
3822        String JavaDoc pagePath = "";
3823        
3824        try
3825        {
3826            pagePath = this.nodeDeliveryController.getPagePath(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, this.contentId, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext);
3827        }
3828        catch(Exception JavaDoc e)
3829        {
3830            logger.error("An error occurred trying to get current page url:" + e.getMessage(), e);
3831        }
3832                
3833        return pagePath;
3834    }
3835
3836    /**
3837     * This method returns the parent siteNode to the given siteNode.
3838     */

3839     
3840    public SiteNodeVO getParentSiteNode(Integer JavaDoc siteNodeId)
3841    {
3842        SiteNodeVO siteNodeVO = null;
3843        
3844        try
3845        {
3846            siteNodeVO = this.nodeDeliveryController.getParentSiteNode(getDatabase(), siteNodeId);
3847        }
3848        catch(Exception JavaDoc e)
3849        {
3850            logger.warn("An error occurred trying to get parent siteNode:" + e.getMessage(), e);
3851        }
3852                
3853        return siteNodeVO;
3854    }
3855
3856    /**
3857     * This method deliveres a new url pointing to the same address as now but in the language
3858     * corresponding to the code sent in.
3859     */

3860     
3861    public String JavaDoc getPageUrlAfterLanguageChange(String JavaDoc languageCode)
3862    {
3863        String JavaDoc pageUrl = "";
3864        
3865        try
3866        {
3867            LanguageVO languageVO = LanguageDeliveryController.getLanguageDeliveryController().getLanguageWithCode(getDatabase(), languageCode);
3868            //pageUrl = this.nodeDeliveryController.getPageUrl(this.siteNodeId, languageVO.getLanguageId(), this.contentId);
3869
pageUrl = this.nodeDeliveryController.getPageUrlAfterLanguageChange(getDatabase(), this.getPrincipal(), this.siteNodeId, languageVO.getLanguageId(), this.contentId, this.deliveryContext);
3870        }
3871        catch(Exception JavaDoc e)
3872        {
3873            logger.error("An error occurred trying to get the new page-url after language-change:" + e.getMessage(), e);
3874        }
3875                
3876        return pageUrl;
3877    }
3878
3879
3880    /**
3881     * This method deliveres a String with the Navigation title the page the user are on has.
3882     * The navigation-title is fetched from the meta-info-content bound to the site node.
3883     */

3884     
3885    public String JavaDoc getPageTitle()
3886    {
3887        String JavaDoc navTitle = "";
3888        
3889        try
3890        {
3891            navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, null, META_INFO_BINDING_NAME, TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, false);
3892        }
3893        catch(Exception JavaDoc e)
3894        {
3895            logger.error("An error occurred trying to get the page navigationtitle:" + e.getMessage(), e);
3896        }
3897                
3898        return navTitle;
3899    }
3900
3901    /**
3902     * This method deliveres a String with the Navigation title the page asked for has.
3903     * As the siteNode can have multiple bindings the method requires a bindingName
3904     * which refers to the AvailableServiceBinding.name-attribute. The navigation-title is fetched
3905     * from the meta-info-content bound to the site node.
3906     */

3907     
3908    public String JavaDoc getPageNavTitle(String JavaDoc structureBindningName)
3909    {
3910        return getPageNavTitle(structureBindningName, false);
3911    }
3912    
3913    /**
3914     * This method deliveres a String with the Navigation title the page asked for has.
3915     * As the siteNode can have multiple bindings the method requires a bindingName
3916     * which refers to the AvailableServiceBinding.name-attribute. The navigation-title is fetched
3917     * from the meta-info-content bound to the site node.
3918     */

3919     
3920    public String JavaDoc getPageNavTitle(String JavaDoc structureBindningName, boolean escapeHTML)
3921    {
3922        String JavaDoc navTitle = "";
3923        
3924        try
3925        {
3926            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName);
3927            logger.info(siteNodeVO.getName());
3928            navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML);
3929        }
3930        catch(Exception JavaDoc e)
3931        {
3932            logger.error("An error occurred trying to get the page navigationtitle on " + this.getCurrentPagePath() + ": " + e.getMessage(), e);
3933        }
3934                
3935        return navTitle;
3936    }
3937
3938    /**
3939     * This method deliveres a String with the Navigation title the page asked for has.
3940     * The navigation-title is fetched from the meta-info-content bound to the site node.
3941     */

3942     
3943    public String JavaDoc getPageNavTitle(Integer JavaDoc siteNodeId)
3944    {
3945        return getPageNavTitle(siteNodeId, false);
3946    }
3947    
3948    /**
3949     * This method deliveres a String with the Navigation title the page asked for has.
3950     * The navigation-title is fetched from the meta-info-content bound to the site node.
3951     */

3952     
3953    public String JavaDoc getPageNavTitle(Integer JavaDoc siteNodeId, boolean escapeHTML)
3954    {
3955        String JavaDoc navTitle = "";
3956        
3957        try
3958        {
3959            navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML);
3960        }
3961        catch(Exception JavaDoc e)
3962        {
3963            logger.warn("An error occurred trying to get the page navigationtitle on " + this.getCurrentPagePath() + ": " + e.getMessage(), e);
3964        }
3965                
3966        return navTitle;
3967    }
3968
3969    /**
3970     * This method deliveres a String with the Navigation title the page asked for has.
3971     * As the siteNode can have multiple bindings the method requires a bindingName and a collection index.
3972     * The navigation-title is fetched from the meta-info-content bound to the site node.
3973     */

3974     
3975    public String JavaDoc getPageNavTitle(String JavaDoc structureBindningName, int index)
3976    {
3977        return getPageNavTitle(structureBindningName, index, false);
3978    }
3979    
3980    /**
3981     * This method deliveres a String with the Navigation title the page asked for has.
3982     * As the siteNode can have multiple bindings the method requires a bindingName and a collection index.
3983     * The navigation-title is fetched from the meta-info-content bound to the site node.
3984     */

3985     
3986    public String JavaDoc getPageNavTitle(String JavaDoc structureBindningName, int index, boolean escapeHTML)
3987    {
3988        String JavaDoc navTitle = "";
3989        
3990        try
3991        {
3992            SiteNodeVO siteNodeVO = this.nodeDeliveryController.getBoundSiteNode(getDatabase(), this.siteNodeId, structureBindningName, index);
3993            logger.info(siteNodeVO.getName());
3994            navTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML);
3995        }
3996        catch(Exception JavaDoc e)
3997        {
3998            logger.error("An error occurred trying to get the page navigationtitle on " + this.getCurrentPagePath() + ": " + e.getMessage(), e);
3999        }
4000                
4001        return navTitle;
4002    }
4003
4004
4005    /**
4006     * This method returns true if the if the page in question (ie sitenode) has page-caching disabled.
4007     * This is essential to turn off when you have a dynamic page like an external application or searchresult.
4008     */

4009    
4010    public boolean getIsPageCacheDisabled()
4011    {
4012        boolean isPageCacheDisabled = false;
4013        
4014        try
4015        {
4016            isPageCacheDisabled = this.nodeDeliveryController.getIsPageCacheDisabled(getDatabase(), this.siteNodeId);
4017        }
4018        catch(Exception JavaDoc e)
4019        {
4020            logger.warn("An error occurred trying to get if the siteNodeVersion has disabled pageCache:" + e.getMessage(), e);
4021        }
4022                
4023        return isPageCacheDisabled;
4024    }
4025    
4026    /**
4027     * This method returns the contenttype this page should return. This is important when sending assets or css:contents.
4028     */

4029    
4030    public String JavaDoc getPageContentType()
4031    {
4032        String JavaDoc pageContentType = "text/html";
4033        
4034        try
4035        {
4036            SiteNodeVersionVO latestSiteNodeVersionVO = this.nodeDeliveryController.getLatestActiveSiteNodeVersionVO(getDatabase(), this.siteNodeId);
4037            if(latestSiteNodeVersionVO != null && latestSiteNodeVersionVO.getContentType() != null && latestSiteNodeVersionVO.getContentType().length() > 0)
4038                pageContentType = latestSiteNodeVersionVO.getContentType();
4039        }
4040        catch(Exception JavaDoc e)
4041        {
4042            logger.warn("An error occurred trying to get the content type of the page:" + e.getMessage(), e);
4043        }
4044                
4045        return pageContentType;
4046    }
4047
4048    /**
4049     * This method returns true if the page in question (ie sitenode) has it's protected property enabled.
4050     * This is essential when checking if we should authenticate users before allowing them access.
4051     */

4052    
4053    public boolean getIsPageProtected()
4054    {
4055        boolean isPageProtected = false;
4056        
4057        try
4058        {
4059            isPageProtected = this.nodeDeliveryController.getIsPageProtected(getDatabase(), this.siteNodeId);
4060        }
4061        catch(Exception JavaDoc e)
4062        {
4063            logger.warn("An error occurred trying to get if the siteNodeVersion has protect page:" + e.getMessage(), e);
4064        }
4065                
4066        return isPageProtected;
4067    }
4068    
4069    public boolean getIsInPageComponentMode()
4070    {
4071        boolean isInPageComponentMode = false;
4072        
4073        try
4074        {
4075            if(this instanceof EditOnSiteBasicTemplateController)
4076                isInPageComponentMode = true;
4077        }
4078        catch(Exception JavaDoc e)
4079        {
4080            logger.warn("An error occurred trying to get if the user was is editing mode:" + e.getMessage(), e);
4081        }
4082                
4083        return isInPageComponentMode;
4084    }
4085
4086    /**
4087     * This method returns true if the page in question (ie sitenode) has page-caching disabled.
4088     * This is essential to turn off when you have a dynamic page like an external application or searchresult.
4089     */

4090    
4091    public boolean getIsEditOnSightDisabled()
4092    {
4093        boolean isEditOnSightDisabled = false;
4094        
4095        try
4096        {
4097            isEditOnSightDisabled = this.nodeDeliveryController.getIsEditOnSightDisabled(getDatabase(), this.siteNodeId);
4098        }
4099        catch(Exception JavaDoc e)
4100        {
4101            logger.warn("An error occurred trying to get if the siteNodeVersion has disabled editOnSight:" + e.getMessage(), e);
4102        }
4103                
4104        return isEditOnSightDisabled;
4105    }
4106
4107
4108    /**
4109     * This method returns a list of all languages available on the current site/repository.
4110     */

4111    
4112    public List JavaDoc getAvailableLanguages()
4113    {
4114        List JavaDoc availableLanguages = new ArrayList JavaDoc();
4115        
4116        try
4117        {
4118            availableLanguages = LanguageDeliveryController.getLanguageDeliveryController().getAvailableLanguages(getDatabase(), this.siteNodeId);
4119        }
4120        catch(Exception JavaDoc e)
4121        {
4122            logger.error("An error occurred trying to get all available languages:" + e.getMessage(), e);
4123        }
4124                
4125        return availableLanguages;
4126    }
4127    
4128    
4129    /**
4130     * This method returns a list of all languages available on the current sitenode. The logic is that
4131     * we check which languages are found in the meta-content in the current mode.
4132     * @deprecated - Use the new getPageLanguages instead
4133     */

4134    
4135    public List JavaDoc getNodeAvailableLanguages()
4136    {
4137        return getNodeAvailableLanguages(this.siteNodeId);
4138    }
4139
4140    /**
4141     * This method returns a list of all languages available on the current sitenode. The logic is that
4142     * we check which languages are found in the meta-content in the current mode.
4143     * @deprecated - Use the new getPageLanguages instead
4144     */

4145    
4146    public List JavaDoc getNodeAvailableLanguages(Integer JavaDoc siteNodeId)
4147    {
4148        List JavaDoc availableLanguages = new ArrayList JavaDoc();
4149        
4150        try
4151        {
4152            availableLanguages = LanguageDeliveryController.getLanguageDeliveryController().getAvailableLanguages(getDatabase(), siteNodeId);
4153            Iterator JavaDoc languageIterator = availableLanguages.iterator();
4154            while(languageIterator.hasNext())
4155            {
4156                LanguageVO languageVO = (LanguageVO)languageIterator.next();
4157                ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, META_INFO_BINDING_NAME, this.deliveryContext);
4158                ContentVersionVO contentVersionVO = null;
4159                if(contentVO != null)
4160                {
4161                    contentVersionVO = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), siteNodeId, contentVO.getId(), languageVO.getId(), false, this.deliveryContext, this.infoGluePrincipal);
4162                }
4163                
4164                if(contentVO == null || contentVersionVO == null)
4165                {
4166                    logger.warn("The meta-info did not have a version of " + languageVO.getName());
4167                    languageIterator.remove();
4168                }
4169            }
4170        }
4171        catch(Exception JavaDoc e)
4172        {
4173            logger.error("An error occurred trying to get all available languages:" + e.getMessage(), e);
4174        }
4175                
4176        return availableLanguages;
4177    }
4178    
4179    /**
4180     * This method returns a list of all languages available on the current sitenode. This method will return all languages enabled for this repository minus
4181     * any disabled languages for the siteNode.
4182     */

4183    
4184    public List JavaDoc getPageLanguages()
4185    {
4186        return getPageLanguages(this.siteNodeId);
4187    }
4188
4189    /**
4190     * This method returns a list of all languages available on the current sitenode. This method will return all languages enabled for this repository minus
4191     * any disabled languages for the siteNode.
4192     */

4193
4194    public List JavaDoc getPageLanguages(Integer JavaDoc siteNodeId)
4195    {
4196        List JavaDoc availableLanguages = new ArrayList JavaDoc();
4197        
4198        try
4199        {
4200            availableLanguages = LanguageDeliveryController.getLanguageDeliveryController().getLanguagesForSiteNode(getDatabase(), siteNodeId, this.getPrincipal());
4201        }
4202        catch(Exception JavaDoc e)
4203        {
4204            logger.error("An error occurred trying to get all available languages:" + e.getMessage(), e);
4205        }
4206                
4207        return availableLanguages;
4208    }
4209
4210    
4211    /**
4212     * The method returns a list of WebPage-objects that is the children of the current
4213     * siteNode. The method is great for navigation-purposes on a structured site.
4214     */

4215    
4216    public List JavaDoc getChildPages()
4217    {
4218        return getChildPages(false);
4219    }
4220
4221    /**
4222     * The method returns a list of WebPage-objects that is the children of the current
4223     * siteNode. The method is great for navigation-purposes on a structured site.
4224     */

4225    
4226    public List JavaDoc getChildPages(boolean escapeHTML)
4227    {
4228        return getChildPages(false, false);
4229    }
4230    
4231    /**
4232     * The method returns a list of WebPage-objects that is the children of the current
4233     * siteNode. The method is great for navigation-purposes on a structured site.
4234     */

4235    
4236    public List JavaDoc getChildPages(boolean escapeHTML, boolean hideUnauthorizedPages)
4237    {
4238        List JavaDoc childPages = new ArrayList JavaDoc();
4239        try
4240        {
4241            List JavaDoc childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), this.siteNodeId);
4242            childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages);
4243        }
4244        catch(Exception JavaDoc e)
4245        {
4246            logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e);
4247        }
4248        
4249        return childPages;
4250    }
4251                                                                                                                                
4252
4253    /**
4254     * The method returns a list of WebPage-objects that is the children of the given
4255     * siteNode. The method is great for navigation-purposes on a structured site.
4256     */

4257    
4258    public List JavaDoc getChildPages(String JavaDoc structureBindingName)
4259    {
4260        return getChildPages(structureBindingName, false);
4261    }
4262
4263    /**
4264     * The method returns a list of WebPage-objects that is the children of the given
4265     * siteNode. The method is great for navigation-purposes on a structured site.
4266     */

4267    
4268    public List JavaDoc getChildPages(String JavaDoc structureBindingName, boolean escapeHTML)
4269    {
4270        return getChildPages(structureBindingName, escapeHTML, false);
4271    }
4272
4273    /**
4274     * The method returns a list of WebPage-objects that is the children of the given
4275     * siteNode. The method is great for navigation-purposes on a structured site.
4276     */

4277    
4278    public List JavaDoc getChildPages(String JavaDoc structureBindingName, boolean escapeHTML, boolean hideUnauthorizedPages)
4279    {
4280        List JavaDoc childPages = new ArrayList JavaDoc();
4281        try
4282        {
4283            List JavaDoc childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), this.getSiteNodeId(structureBindingName));
4284            childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages);
4285        }
4286        catch(Exception JavaDoc e)
4287        {
4288            logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e);
4289        }
4290        
4291        return childPages;
4292    }
4293
4294    /**
4295     * This method takes a list of sitenodes and converts it to a page list instead.
4296     *
4297     * @param childNodeVOList
4298     * @param escapeHTML
4299     * @param hideUnauthorizedPages
4300     * @return
4301     * @throws Exception
4302     */

4303    private List JavaDoc getPages(List JavaDoc childNodeVOList, boolean escapeHTML, boolean hideUnauthorizedPages) throws Exception JavaDoc
4304    {
4305        List JavaDoc childPages = new ArrayList JavaDoc();
4306
4307        Iterator JavaDoc i = childNodeVOList.iterator();
4308        while(i.hasNext())
4309        {
4310            SiteNodeVO siteNodeVO = (SiteNodeVO)i.next();
4311            if(!hideUnauthorizedPages || getHasUserPageAccess(siteNodeVO.getId()))
4312            {
4313                try
4314                {
4315                    WebPage webPage = new WebPage();
4316                    webPage.setSiteNodeId(siteNodeVO.getSiteNodeId());
4317                    webPage.setLanguageId(this.languageId);
4318                    webPage.setContentId(null);
4319                    webPage.setNavigationTitle(this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, USE_LANGUAGE_FALLBACK, this.deliveryContext, escapeHTML));
4320                    webPage.setMetaInfoContentId(this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, USE_INHERITANCE, this.deliveryContext));
4321                    webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext));
4322                    childPages.add(webPage);
4323                }
4324                catch(Exception JavaDoc e)
4325                {
4326                    logger.info("An error occurred when looking up one of the childPages:" + e.getMessage(), e);
4327                }
4328            }
4329        }
4330        
4331        return childPages;
4332    }
4333    
4334    /**
4335     * The method returns a list of WebPage-objects that is the children of the given
4336     * siteNode. The method is great for navigation-purposes on a structured site.
4337     */

4338    
4339    public List JavaDoc getChildPages(Integer JavaDoc siteNodeId)
4340    {
4341        return getChildPages(siteNodeId, false, false);
4342    }
4343
4344    /**
4345     * The method returns a list of WebPage-objects that is the children of the given
4346     * siteNode. The method is great for navigation-purposes on a structured site.
4347     */

4348    
4349    public List JavaDoc getChildPages(Integer JavaDoc siteNodeId, boolean escapeHTML)
4350    {
4351        return getChildPages(siteNodeId, escapeHTML, false);
4352    }
4353
4354    /**
4355     * The method returns a list of WebPage-objects that is the children of the given
4356     * siteNode. The method is great for navigation-purposes on a structured site.
4357     */

4358    
4359    public List JavaDoc getChildPages(Integer JavaDoc siteNodeId, boolean escapeHTML, boolean hideUnauthorizedPages)
4360    {
4361        List JavaDoc childPages = new ArrayList JavaDoc();
4362        try
4363        {
4364            List JavaDoc childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), siteNodeId);
4365            childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages);
4366        }
4367        catch(Exception JavaDoc e)
4368        {
4369            logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e);
4370        }
4371        
4372        return childPages;
4373    }
4374
4375    /**
4376     * The method returns a list of WebPage-objects that is the children of the given
4377     * siteNode. The method is great for navigation-purposes on a structured site.
4378     */

4379    
4380    public List JavaDoc getChildPages(Integer JavaDoc siteNodeId, String JavaDoc sortAttribute, String JavaDoc sortOrder)
4381    {
4382        return getChildPages(siteNodeId, sortAttribute, sortOrder, false, false);
4383    }
4384
4385    /**
4386     * The method returns a list of WebPage-objects that is the children of the given
4387     * siteNode. The method is great for navigation-purposes on a structured site.
4388     */

4389    
4390    public List JavaDoc getChildPages(Integer JavaDoc siteNodeId, String JavaDoc sortAttribute, String JavaDoc sortOrder, boolean hideUnauthorizedPages)
4391    {
4392        return getChildPages(siteNodeId, sortAttribute, sortOrder, false, hideUnauthorizedPages);
4393    }
4394
4395    /**
4396     * The method returns a list of WebPage-objects that is the children of the given
4397     * siteNode. The method is great for navigation-purposes on a structured site.
4398     */

4399    
4400    public List JavaDoc getChildPages(Integer JavaDoc siteNodeId, String JavaDoc sortAttribute, String JavaDoc sortOrder, boolean escapeHTML, boolean hideUnauthorizedPages)
4401    {
4402        List JavaDoc childPages = new ArrayList JavaDoc();
4403        try
4404        {
4405            List JavaDoc childNodeVOList = this.nodeDeliveryController.getChildSiteNodes(getDatabase(), siteNodeId);
4406            Collections.sort(childNodeVOList, new SiteNodeComparator(sortAttribute, sortOrder, this));
4407            childPages = getPages(childNodeVOList, escapeHTML, hideUnauthorizedPages);
4408        }
4409        catch(Exception JavaDoc e)
4410        {
4411            logger.error("An error occurred trying to get the page childPages:" + e.getMessage(), e);
4412        }
4413        
4414        return childPages;
4415    }
4416    
4417
4418    /**
4419     * The method returns a list of WebPage-objects that is the bound sitenodes of named binding.
4420     * The method is great for navigation-purposes on any site.
4421     */

4422    
4423    public List JavaDoc getBoundPages(String JavaDoc structureBindningName)
4424    {
4425        return getBoundPages(structureBindningName, false, false);
4426    }
4427
4428    /**
4429     * The method returns a list of WebPage-objects that is the bound sitenodes of named binding.
4430     * The method is great for navigation-purposes on any site.
4431     */

4432
4433    public List JavaDoc getBoundPages(String JavaDoc structureBindningName, boolean escapeHTML)
4434    {
4435        return getBoundPages(structureBindningName, escapeHTML, false);
4436    }
4437
4438    /**
4439     * The method returns a list of WebPage-objects that is the bound sitenodes of named binding.
4440     * The method is great for navigation-purposes on any site.
4441     */

4442
4443    public List JavaDoc getBoundPages(String JavaDoc structureBindningName, boolean escapeHTML, boolean hideUnauthorizedPages)
4444    {
4445        return getBoundPages(this.siteNodeId, structureBindningName, escapeHTML, false);
4446    }
4447    
4448
4449    public List JavaDoc getBoundPages(Integer JavaDoc siteNodeId, String JavaDoc structureBindningName)
4450    {
4451        return getBoundPages(siteNodeId, structureBindningName, false, false);
4452    }
4453
4454    public List JavaDoc getBoundPages(Integer JavaDoc siteNodeId, String JavaDoc structureBindningName, boolean escapeHTML)
4455    {
4456        return getBoundPages(siteNodeId, structureBindningName, escapeHTML, false);
4457    }
4458
4459    private HashMap JavaDoc cachedBindings = new HashMap JavaDoc();
4460
4461    /**
4462     * This methods get a list of bound pages with the structureBindningName sent in which resides on the siteNodeId sent in.
4463     */

4464    
4465    public List JavaDoc getBoundPages(Integer JavaDoc siteNodeId, String JavaDoc structureBindningName, boolean escapeHTML, boolean hideUnauthorizedPages)
4466    {
4467        //Checking for a read binding in this request...
4468
if(cachedBindings.containsKey(siteNodeId + "_" + structureBindningName + "_" + hideUnauthorizedPages))
4469            return (List JavaDoc)cachedBindings.get(siteNodeId + "_" + structureBindningName + "_" + hideUnauthorizedPages);
4470
4471        List JavaDoc boundPages = new ArrayList JavaDoc();
4472        try
4473        {
4474            List JavaDoc siteNodeVOList = this.nodeDeliveryController.getBoundSiteNodes(getDatabase(), siteNodeId, structureBindningName);
4475            boundPages = getPages(siteNodeVOList, escapeHTML, hideUnauthorizedPages);
4476        }
4477        catch(Exception JavaDoc e)
4478        {
4479            logger.error("An error occurred trying to get the bound pages:" + e.getMessage(), e);
4480        }
4481        
4482        //Caching bindings
4483
cachedBindings.put(siteNodeId + "_" + structureBindningName + "_" + hideUnauthorizedPages, boundPages);
4484        
4485        return boundPages;
4486    }
4487
4488
4489    
4490    /**
4491     * The method returns a list of WebPage-objects that is the bound sitenodes of named binding.
4492     * The method is great for navigation-purposes on any site.
4493     * We also filter out all pages that don't have a localized version of the page meta-content.
4494     */

4495
4496    public List JavaDoc getLocalizedBoundPages(String JavaDoc structureBindningName)
4497    {
4498        //Checking for a read binding in this request...
4499
if(cachedBindings.containsKey(structureBindningName))
4500            return (List JavaDoc)cachedBindings.get(structureBindningName);
4501            
4502        List JavaDoc boundPages = new ArrayList JavaDoc();
4503        try
4504        {
4505            List JavaDoc siteNodeVOList = this.nodeDeliveryController.getBoundSiteNodes(getDatabase(), this.siteNodeId, structureBindningName);
4506            
4507            Iterator JavaDoc i = siteNodeVOList.iterator();
4508            while(i.hasNext())
4509            {
4510                SiteNodeVO siteNodeVO = (SiteNodeVO)i.next();
4511
4512                try
4513                {
4514                    Integer JavaDoc metaInfoContentId = this.nodeDeliveryController.getMetaInfoContentId(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), META_INFO_BINDING_NAME, DO_NOT_USE_INHERITANCE, this.deliveryContext);
4515                    String JavaDoc navigationTitle = this.nodeDeliveryController.getPageNavigationTitle(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, META_INFO_BINDING_NAME, NAV_TITLE_ATTRIBUTE_NAME, DO_NOT_USE_LANGUAGE_FALLBACK, this.deliveryContext, false);
4516                    if(metaInfoContentId != null && navigationTitle != null && !navigationTitle.equals(""))
4517                    {
4518                        WebPage webPage = new WebPage();
4519                        webPage.setSiteNodeId(siteNodeVO.getSiteNodeId());
4520                        webPage.setLanguageId(this.languageId);
4521                        webPage.setContentId(null);
4522                        webPage.setNavigationTitle(navigationTitle);
4523                        webPage.setMetaInfoContentId(metaInfoContentId);
4524                        webPage.setUrl(this.nodeDeliveryController.getPageUrl(getDatabase(), this.getPrincipal(), siteNodeVO.getSiteNodeId(), this.languageId, null, this.deliveryContext));
4525                        boundPages.add(webPage);
4526                    }
4527                }
4528                catch(Exception JavaDoc e)
4529                {
4530                    logger.info("An error occurred when looking up one of the getLocalizedBoundPages:" + e.getMessage(), e);
4531                }
4532            }
4533        }
4534        catch(Exception JavaDoc e)
4535        {
4536            logger.error("An error occurred trying to get the bound pages:" + e.getMessage(), e);
4537        }
4538        
4539        //Caching bindings
4540
cachedBindings.put(structureBindningName, boundPages);
4541        
4542        return boundPages;
4543    }
4544                                                                                                                                
4545
4546
4547    /**
4548     * The method returns a single ContentVO-objects that is the bound content of named binding.
4549     * It's used for getting one content.
4550     */

4551    
4552    public ContentVO getBoundContent(String JavaDoc structureBindningName)
4553    {
4554        ContentVO content = null;
4555        
4556        List JavaDoc contents = getBoundContents(structureBindningName);
4557        
4558        if(contents != null && contents.size() > 0)
4559            content = (ContentVO)contents.get(0);
4560        
4561        return content;
4562    }
4563
4564
4565    /**
4566     * The method returns a list of ContentVO-objects that is the bound content of named binding.
4567     * The method is great for collection-pages on any site.
4568     */

4569    
4570    public List JavaDoc getBoundContents(String JavaDoc structureBindningName)
4571    {
4572        //Checking for a read binding in this request...
4573
if(cachedBindings.containsKey(structureBindningName))
4574            return (List JavaDoc)cachedBindings.get(structureBindningName);
4575            
4576        List JavaDoc boundContents = new ArrayList JavaDoc();
4577        try
4578        {
4579            boundContents = this.nodeDeliveryController.getBoundContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, structureBindningName, USE_INHERITANCE, true, this.deliveryContext);
4580        }
4581        catch(Exception JavaDoc e)
4582        {
4583            logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e);
4584        }
4585        
4586        //Caching bindings
4587
cachedBindings.put(structureBindningName, boundContents);
4588        
4589        return boundContents;
4590    }
4591
4592
4593    /**
4594     * The method returns a list of ContentVO-objects that is children to the bound content of named binding.
4595     * The method is great for collection-pages on any site where you want to bind to a folder containing all contents to list.
4596     * You can also state if the method should recurse into subfolders and how the contents should be sorted.
4597     * The recursion only deals with three levels at the moment for performance-reasons.
4598     */

4599    
4600    public List JavaDoc getBoundFolderContents(String JavaDoc structureBindningName, boolean searchRecursive, String JavaDoc sortAttribute, String JavaDoc sortOrder)
4601    {
4602        List JavaDoc boundContents = new ArrayList JavaDoc();
4603        try
4604        {
4605            boundContents = this.nodeDeliveryController.getBoundFolderContents(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, structureBindningName, searchRecursive, new Integer JavaDoc(3), sortAttribute, sortOrder, USE_LANGUAGE_FALLBACK, false, this.deliveryContext);
4606        }
4607        catch(Exception JavaDoc e)
4608        {
4609            logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e);
4610        }
4611        
4612        return boundContents;
4613    }
4614
4615
4616    /**
4617     * The method returns a list of ContentVO-objects that is children to the bound content of named binding on the siteNode sent in.
4618     * The method is great for collection-pages on any site where you want to bind to a folder containing all contents to list.
4619     * You can also state if the method should recurse into subfolders and how the contents should be sorted.
4620     * The recursion only deals with three levels at the moment for performance-reasons.
4621     */

4622    
4623    public List JavaDoc getBoundFolderContents(Integer JavaDoc siteNodeId, String JavaDoc structureBindningName, boolean searchRecursive, String JavaDoc sortAttribute, String JavaDoc sortOrder)
4624    {
4625        List JavaDoc boundContents = new ArrayList JavaDoc();
4626        try
4627        {
4628            boundContents = this.nodeDeliveryController.getBoundFolderContents(getDatabase(), this.getPrincipal(), siteNodeId, this.languageId, structureBindningName, searchRecursive, new Integer JavaDoc(3), sortAttribute, sortOrder, USE_LANGUAGE_FALLBACK, false, this.deliveryContext);
4629        }
4630        catch(Exception JavaDoc e)
4631        {
4632            logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e);
4633        }
4634        
4635        return boundContents;
4636    }
4637
4638    /**
4639     * The method returns a list of ContentVO-objects that is children to the bound content sent in.
4640     * The method is great for collection-pages on any site where you want to bind to a folder containing all contents to list.
4641     * You can also state if the method should recurse into subfolders and how the contents should be sorted.
4642     * The recursion only deals with three levels at the moment for performance-reasons.
4643     */

4644    
4645    public List JavaDoc getChildContents(Integer JavaDoc contentId, boolean searchRecursive, String JavaDoc sortAttribute, String JavaDoc sortOrder)
4646    {
4647        return getChildContents(contentId, searchRecursive, sortAttribute, sortOrder, false);
4648    }
4649
4650
4651    /**
4652     * The method returns a list of ContentVO-objects that is children to the bound content sent in.
4653     * The method is great for collection-pages on any site where you want to bind to a folder containing all contents to list.
4654     * You can also state if the method should recurse into subfolders and how the contents should be sorted.
4655     * The recursion only deals with three levels at the moment for performance-reasons.
4656     */

4657    
4658    public List JavaDoc getChildContents(Integer JavaDoc contentId, boolean searchRecursive, String JavaDoc sortAttribute, String JavaDoc sortOrder, boolean includeFolders)
4659    {
4660        List JavaDoc childContents = new ArrayList JavaDoc();
4661        try
4662        {
4663            childContents = this.nodeDeliveryController.getBoundFolderContents(getDatabase(), this.getPrincipal(), contentId, this.languageId, searchRecursive, new Integer JavaDoc(3), sortAttribute, sortOrder, USE_LANGUAGE_FALLBACK, includeFolders, this.deliveryContext);
4664        }
4665        catch(Exception JavaDoc e)
4666        {
4667            logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e);
4668        }
4669        
4670        return childContents;
4671    }
4672
4673    
4674    /**
4675     * The method returns the ContentTypeVO-objects of the given contentId.
4676     */

4677    
4678    public ContentTypeDefinitionVO getContentTypeDefinitionVO(Integer JavaDoc contentId)
4679    {
4680        ContentTypeDefinitionVO contentTypeDefinition = null;
4681        
4682        try
4683        {
4684            contentTypeDefinition = ContentDeliveryController.getContentDeliveryController().getContentTypeDefinitionVO(this.getDatabase(), contentId);
4685            
4686        }
4687        catch(Exception JavaDoc e)
4688        {
4689            logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e);
4690        }
4691        
4692        return contentTypeDefinition;
4693    }
4694    
4695    /**
4696     * The method returns the ContentTypeVO-object with the given name.
4697     */

4698    
4699    public ContentTypeDefinitionVO getContentTypeDefinitionVO(String JavaDoc name)
4700    {
4701        ContentTypeDefinitionVO contentTypeDefinition = null;
4702        
4703        try
4704        {
4705            contentTypeDefinition = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName(name, getDatabase());
4706        }
4707        catch(Exception JavaDoc e)
4708        {
4709            logger.error("An error occurred trying to get the bound contents:" + e.getMessage(), e);
4710        }
4711        
4712        return contentTypeDefinition;
4713    }
4714
4715    /**
4716     * The method returns a list of WebPage-objects that is the bound sitenodes of named binding.
4717     * The method is great for navigation-purposes on any site. Improve later so the list is cached
4718     * once for every instance. Otherwise we fetch the whole list again and its not necessairy as
4719     * this controller only concerns one request.
4720     */

4721    
4722    public WebPage getBoundPage(String JavaDoc structureBindningName, int position)
4723    {
4724        List JavaDoc boundPages = getBoundPages(structureBindningName);
4725        
4726        if(boundPages.size() > position)
4727            return (WebPage)boundPages.get(position);
4728        else
4729            return null;
4730    }
4731
4732
4733    /**
4734     * This method allows a user to get any string rendered as a template.
4735     */

4736
4737    public String JavaDoc renderString(String JavaDoc template)
4738    {
4739        String JavaDoc result = "";
4740        
4741        try
4742        {
4743            Map JavaDoc context = new HashMap JavaDoc();
4744            context.put("inheritedTemplateLogic", this);
4745            context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext));
4746
4747            // Add the templateLogicContext objects to this context. (SS - 040219)
4748
context.putAll(templateLogicContext);
4749            
4750            StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
4751            PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
4752            new VelocityTemplateProcessor().renderTemplate(context, cachedStream, template);
4753            result = cacheString.toString();
4754        }
4755        catch(Exception JavaDoc e)
4756        {
4757            logger.error("An error occurred trying to do an include:" + e.getMessage(), e);
4758        }
4759            
4760        return result;
4761    }
4762
4763    /**
4764     * This method allows a user to get any string rendered as a template.
4765     */

4766
4767    public String JavaDoc renderString(String JavaDoc template, boolean useSubContext)
4768    {
4769        String JavaDoc result = "";
4770        
4771        try
4772        {
4773            Map JavaDoc context = new HashMap JavaDoc();
4774            if(!useSubContext)
4775                context.put("templateLogic", this);
4776            else
4777            {
4778                context.put("inheritedTemplateLogic", this);
4779                context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext));
4780            }
4781            
4782            // Add the templateLogicContext objects to this context. (SS - 040219)
4783
context.putAll(templateLogicContext);
4784            
4785            StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
4786            PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
4787            new VelocityTemplateProcessor().renderTemplate(context, cachedStream, template);
4788            result = cacheString.toString();
4789        }
4790        catch(Exception JavaDoc e)
4791        {
4792            logger.error("An error occurred trying to do an include:" + e.getMessage(), e);
4793        }
4794            
4795        return result;
4796    }
4797
4798    /**
4799     * This method allows the current template to include another template which is also rendered
4800     * in the current context as if it were a part. The method assumes that the result can be cached.
4801     * Use the other include method if you wish to be able to control if the result is cached or not.
4802     */

4803    
4804    
4805    public String JavaDoc include(String JavaDoc contentBindningName, String JavaDoc attributeName)
4806    {
4807        return include(contentBindningName, attributeName, true);
4808    }
4809
4810    public String JavaDoc include(String JavaDoc contentBindningName, String JavaDoc attributeName, boolean cacheInclude)
4811    {
4812        return include(contentBindningName, attributeName, cacheInclude, null, null);
4813    }
4814    
4815    /**
4816     * This method allows the current template to include another template which is also rendered
4817     * in the current context as if it were a part.
4818     * Use this method if you wish to be able to control if the result is cached or not.
4819     */

4820    public String JavaDoc include(String JavaDoc contentBindningName, String JavaDoc attributeName, boolean cacheInclude, String JavaDoc cName, Object JavaDoc cObject)
4821    {
4822        String JavaDoc includeKey = "" + this.siteNodeId + "_" + this.languageId + "_" + this.contentId + "_" + browserBean.getUseragent() + "_" + contentBindningName + "_" + attributeName;
4823        logger.info("includeKey:" + includeKey);
4824        String JavaDoc result = (String JavaDoc)CacheController.getCachedObject("includeCache", includeKey);
4825        if(result != null)
4826        {
4827            logger.info("There was an cached include:" + result);
4828        }
4829        else
4830        {
4831            try
4832            {
4833                ContentVO contentVO = this.nodeDeliveryController.getBoundContent(getDatabase(), this.getPrincipal(), this.siteNodeId, this.languageId, USE_LANGUAGE_FALLBACK, contentBindningName, this.deliveryContext);
4834                if(contentVO != null)
4835                {
4836                    String JavaDoc includedTemplate = ContentDeliveryController.getContentDeliveryController().getContentAttribute(getDatabase(), contentVO.getContentId(), this.languageId, "Template", this.siteNodeId, USE_LANGUAGE_FALLBACK, this.deliveryContext, this.infoGluePrincipal, false);
4837                    logger.info("Found included template:" + includedTemplate);
4838                    
4839                    Map JavaDoc context = new HashMap JavaDoc();
4840                    context.put("inheritedTemplateLogic", this);
4841                    context.put("templateLogic", getTemplateController(this.siteNodeId, this.languageId, this.contentId, this.request, this.infoGluePrincipal, this.deliveryContext));
4842                    context.put("deliveryContext", this.deliveryContext);
4843                    
4844                    // Add the templateLogicContext objects to this context. (SS - 040219)
4845
context.putAll(templateLogicContext);
4846
4847                    if (cName != null)
4848                        context.put(cName, cObject);
4849        
4850                    StringWriter JavaDoc cacheString = new StringWriter JavaDoc();
4851                    PrintWriter JavaDoc cachedStream = new PrintWriter JavaDoc(cacheString);
4852                    new VelocityTemplateProcessor().renderTemplate(context, cachedStream, includedTemplate);
4853                    result = cacheString.toString();
4854                    
4855                    logger.info("result:" + result);
4856    
4857                    if(cacheInclude)
4858                        CacheController.cacheObject("includeCache", includeKey, result);
4859                }
4860            }
4861            catch(Exception JavaDoc e)
4862            {
4863                logger.error("An error occurred trying to do an include:" + e.getMessage(), e);
4864            }
4865        }
4866        
4867        return result;
4868    }
4869    
4870    
4871    /**
4872     * This method fetches a given URL contents. This means that we can include a external url's contents
4873     * in our application.
4874     */

4875    
4876    public String JavaDoc getUrlContent(String JavaDoc url)
4877    {
4878        String JavaDoc contents = "";
4879        
4880        try
4881        {
4882            logger.info("We are going to do an include on an external webpage: " + url);
4883            contents = this.integrationDeliveryController.getUrlContent(url, request, true);
4884            //logger.info("The respons was: " + contents);
4885
}
4886        catch(Exception JavaDoc e)
4887        {
4888            logger.error("An error occurred trying to do an include the url:" + url, e);
4889        }
4890        
4891        return contents;
4892    }
4893    
4894    /**
4895     * This method fetches a given URL contents. This means that we can include a external url's contents
4896     * in our application. This second method is used to not send extra params through.
4897     */

4898    
4899    public String JavaDoc getUrlContent(String JavaDoc url, boolean includeRequest)
4900    {
4901        String JavaDoc contents = "";
4902        
4903        try
4904        {
4905            logger.info("We are going to do an include on an external webpage: " + url);
4906            contents = this.integrationDeliveryController.getUrlContent(url, request, includeRequest);
4907            //logger.info("The respons was: " + contents);
4908
}
4909        catch(Exception JavaDoc e)
4910        {
4911            logger.error("An error occurred trying to do an include the url:" + url, e);
4912        }
4913        
4914        return contents;
4915    }
4916    
4917    /**
4918     * This method fetches a given URL contents. This means that we can include a external url's contents
4919     * in our application.
4920     */

4921    
4922    public String JavaDoc getUrlContent(String JavaDoc url, String JavaDoc encoding)
4923    {
4924        String JavaDoc contents = "";
4925        
4926        try
4927        {
4928            logger.info("We are going to do an include on an external webpage: " + url);
4929            contents = this.integrationDeliveryController.getUrlContent(url, request, true, encoding);
4930            //logger.info("The respons was: " + contents);
4931
}
4932        catch(Exception JavaDoc e)
4933        {
4934            logger.error("An error occurred trying to do an include the url:" + url, e);
4935        }
4936        
4937        return contents;
4938    }
4939    
4940    /**
4941     * This method fetches a given URL contents. This means that we can include a external url's contents
4942     * in our application. This second method is used to not send extra params through.
4943     */

4944    
4945    public String JavaDoc getUrlContent(String JavaDoc url, boolean includeRequest, String JavaDoc encoding)
4946    {
4947        String JavaDoc contents = "";
4948        
4949        try
4950        {
4951            logger.info("We are going to do an include on an external webpage: " + url);
4952            contents = this.integrationDeliveryController.getUrlContent(url, request, includeRequest, encoding);
4953            //logger.info("The respons was: " + contents);
4954
}
4955        catch(Exception JavaDoc e)
4956        {
4957            logger.error("An error occurred trying to do an include the url:" + url, e);
4958        }
4959        
4960        return contents;
4961    }
4962    
4963
4964    public Object JavaDoc getObjectWithName(String JavaDoc classname)
4965    {
4966        try
4967        {
4968            return this.integrationDeliveryController.getObjectWithName(classname, request);
4969        }
4970        catch (InstantiationException JavaDoc e)
4971        {
4972            e.printStackTrace();
4973        }
4974        catch (IllegalAccessException JavaDoc e)
4975        {
4976            e.printStackTrace();
4977        }
4978        catch (ClassNotFoundException JavaDoc e)
4979        {
4980            e.printStackTrace();
4981        }
4982        return null;
4983    }
4984
4985
4986    /**
4987     * This method lets a user substitute a string located in the page by a regular expression with another
4988     * string. Very useful in certain situations.
4989     */

4990    
4991    public String JavaDoc replace(String JavaDoc originalString, String JavaDoc expressionToReplace, String JavaDoc newString)
4992    {
4993        return originalString.replaceAll(expressionToReplace, newString);
4994    }
4995    
4996    /**
4997     * This method lets a user substitute a string located in the page by a regular expression with another
4998     * string. This method also lets the user specify a subpart of the string to be able to be more
4999     * specific. Very useful in certain situations.
5000     */

5001    
5002    public String JavaDoc replace(String JavaDoc originalString, String JavaDoc substring, String JavaDoc stringToReplace, String JavaDoc newString)
5003    {
5004        StringBuffer JavaDoc result = new StringBuffer JavaDoc();
5005        int startIndex = 0;
5006        int stopIndex = 0;
5007        int offset = 0;
5008        
5009        try
5010        {
5011            List JavaDoc substrings = search(originalString, substring);
5012            
5013            Iterator JavaDoc substringsIterator = substrings.iterator();
5014            while(substringsIterator.hasNext())
5015            {
5016                String JavaDoc currentSubstring = (String JavaDoc)substringsIterator.next();
5017                String JavaDoc newSubstring = currentSubstring.replaceAll(stringToReplace, newString);
5018                startIndex = originalString.indexOf(currentSubstring, offset);
5019                stopIndex = startIndex + currentSubstring.length();
5020                result.append(originalString.substring(offset, startIndex));
5021                result.append(originalString.substring(startIndex, stopIndex));
5022                result.append(newSubstring);
5023                offset = stopIndex;
5024            }
5025    
5026            if(offset < originalString.length())
5027            {
5028                result.append(originalString.substring(offset));
5029            }
5030        }
5031        catch(Exception JavaDoc e)
5032        {
5033            logger.error("The replace function experienced an error:" + e.getMessage(), e);
5034        }
5035        
5036        return result.toString();
5037    }
5038    
5039    
5040
5041    /**
5042     * This method searches for matches to a special expression.
5043     * TODO: Move to an utility class
5044     * @param containsMatches
5045     * @param regexp
5046     * @return
5047     */

5048    
5049    private List JavaDoc search(String JavaDoc containsMatches, String JavaDoc regexp) throws Exception JavaDoc
5050    {
5051        List JavaDoc foundMatches = new ArrayList JavaDoc();
5052        int matches = 0;
5053
5054        PatternCompiler compiler = new Perl5Compiler();
5055        PatternMatcher matcher = new Perl5Matcher();
5056        Pattern pattern = null;
5057        
5058        try
5059        {
5060            pattern = compiler.compile(regexp);
5061        }
5062        catch (MalformedPatternException e)
5063        {
5064            throw new Exception JavaDoc("A bad pattern was entered:" + e.getMessage());
5065        }
5066        
5067        PatternMatcherInput input = new PatternMatcherInput(containsMatches);
5068        
5069        while (matcher.contains(input, pattern))
5070        {
5071            MatchResult result = matcher.getMatch();
5072            ++matches;
5073            foundMatches.add(result.toString());
5074        }
5075        
5076        return foundMatches;
5077    }
5078    
5079    
5080    /**
5081     * This method helps us find out if the current site node is the same as the one sent in.
5082     */

5083    
5084    public boolean getIsCurrentSiteNode(Integer JavaDoc siteNodeId)
5085    {
5086        return this.siteNodeId.equals(siteNodeId);
5087    }
5088        
5089    /**
5090     * This method helps us find out if the current site node is the same or a child to the sent in one.
5091     * So if the current page is a child(in the entire hierarchy below) below the siteNode sent in the
5092     * method returns true. Useful for navigational purposes.
5093     */

5094    
5095    public boolean getIsParentToCurrent(Integer JavaDoc siteNodeId)
5096    {
5097        return getIsParentToCurrentRecursive(siteNodeId, this.siteNodeId);
5098    }
5099    
5100    /**
5101     * This method helps us find out if the current site node is the same or a child to the sent in one.
5102     */

5103    
5104    private boolean getIsParentToCurrentRecursive(Integer JavaDoc siteNodeId, Integer JavaDoc currentSiteNodeId)
5105    {
5106        boolean isParentToCurrent = false;
5107        
5108        try
5109        {
5110            if(currentSiteNodeId != null && siteNodeId != null && currentSiteNodeId.intValue() == siteNodeId.intValue())
5111            {
5112                isParentToCurrent = true;
5113            }
5114            else
5115            {
5116                SiteNodeVO parentSiteNodeVO = this.nodeDeliveryController.getParentSiteNode(getDatabase(), currentSiteNodeId);
5117                if(parentSiteNodeVO != null)
5118                    isParentToCurrent = getIsParentToCurrentRecursive(siteNodeId, parentSiteNodeVO.getSiteNodeId());
5119            }
5120        }
5121        catch(Exception JavaDoc e)
5122        {
5123            logger.error("An error occurred:" + e.getMessage(), e);
5124        }
5125        
5126        return isParentToCurrent;
5127    }
5128    
5129    /**
5130     * This method return true if a localized version with the current language exist
5131     */

5132    
5133    public boolean getHasLocalizedVersion(Integer JavaDoc contentId)
5134    {
5135        boolean ret = false;
5136        try
5137        {
5138            ret = ContentDeliveryController.getContentDeliveryController().getContentVersionVO(getDatabase(), this.siteNodeId, contentId, this.languageId, false, this.deliveryContext, this.infoGluePrincipal) != null;
5139        }
5140        catch(Exception JavaDoc e)
5141        {
5142            logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e);
5143        }
5144        return ret;
5145    }
5146
5147    /**
5148     * This method return true if the user logged in has access to the siteNode sent in.
5149     */

5150    
5151    public boolean getHasUserPageAccess(Integer JavaDoc siteNodeId)
5152    {
5153        boolean hasUserPageAccess = false;
5154        
5155        try
5156        {
5157            Integer JavaDoc protectedSiteNodeVersionId = this.nodeDeliveryController.getProtectedSiteNodeVersionId(getDatabase(), siteNodeId);
5158            if(protectedSiteNodeVersionId == null)
5159            {
5160                logger.info("The page was not protected...");
5161                hasUserPageAccess = true;
5162            }
5163            else
5164            {
5165                logger.info("The page was protected...");
5166                Principal JavaDoc principal = this.getPrincipal();
5167                logger.info("Principal:" + principal);
5168                
5169                if(principal != null)
5170                {
5171                    //SiteNodeVersionVO siteNodeVersionVO = this.nodeDeliveryController.getActiveSiteNodeVersionVO(siteNodeId);
5172
hasUserPageAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, "SiteNodeVersion.Read", protectedSiteNodeVersionId.toString());
5173                }
5174            }
5175        }
5176        catch(Exception JavaDoc e)
5177        {
5178            logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e);
5179        }
5180        
5181        return hasUserPageAccess;
5182    }
5183
5184    /**
5185     * This method return true if the user logged in has access to the siteNode sent in.
5186     */

5187    
5188    public boolean getHasUserPageAccess(Integer JavaDoc siteNodeId, String JavaDoc interceptionPointName)
5189    {
5190        boolean hasUserPageAccess = false;
5191        
5192        try
5193        {
5194            Integer JavaDoc protectedSiteNodeVersionId = this.nodeDeliveryController.getProtectedSiteNodeVersionId(getDatabase(), siteNodeId);
5195            if(protectedSiteNodeVersionId == null)
5196            {
5197                logger.info("The page was not protected...");
5198                hasUserPageAccess = true;
5199            }
5200            else
5201            {
5202                logger.info("The page was protected...");
5203                Principal JavaDoc principal = this.getPrincipal();
5204                logger.info("Principal:" + principal);
5205                
5206                if(principal != null)
5207                {
5208                    //SiteNodeVersionVO siteNodeVersionVO = this.nodeDeliveryController.getActiveSiteNodeVersionVO(siteNodeId);
5209
hasUserPageAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, interceptionPointName, protectedSiteNodeVersionId.toString());
5210                }
5211            }
5212        }
5213        catch(Exception JavaDoc e)
5214        {
5215            logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e);
5216        }
5217        
5218        return hasUserPageAccess;
5219    }
5220
5221    
5222    /**
5223     * This method return true if the user logged in has access to the content sent in.
5224     */

5225    
5226    public boolean getHasUserContentAccess(Integer JavaDoc contentId)
5227    {
5228        boolean hasUserContentAccess = true;
5229        
5230        try
5231        {
5232            if(contentId != null)
5233            {
5234                Integer JavaDoc protectedContentId = ContentDeliveryController.getContentDeliveryController().getProtectedContentId(getDatabase(), contentId);
5235                logger.info("IsProtected:" + protectedContentId);
5236                if(protectedContentId != null && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "Content.Read", protectedContentId.toString()))
5237                {
5238                    hasUserContentAccess = false;
5239                }
5240            }
5241        }
5242        catch(Exception JavaDoc e)
5243        {
5244            logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e);
5245        }
5246        
5247        return hasUserContentAccess;
5248    }
5249
5250    /**
5251     * This method return true if the user logged in has access to do the action on the content sent in.
5252     * @parameter actionId Any action you wish to look for - example "Content.Read"
5253     */

5254    
5255    public boolean getHasUserContentAccess(Integer JavaDoc contentId, String JavaDoc action)
5256    {
5257        boolean hasUserContentAccess = true;
5258        
5259        try
5260        {
5261            Integer JavaDoc protectedContentId = ContentDeliveryController.getContentDeliveryController().getProtectedContentId(getDatabase(), contentId);
5262            logger.info("IsProtected:" + protectedContentId);
5263            if(protectedContentId != null && !AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, action, protectedContentId.toString()))
5264            {
5265                hasUserContentAccess = false;
5266            }
5267        }
5268        catch(Exception JavaDoc e)
5269        {
5270            logger.error("An error occurred trying to get determine if content:" + contentId + " has a localized version:" + e.getMessage(), e);
5271        }
5272        
5273        return hasUserContentAccess;
5274    }
5275    
5276    /**
5277     * This method return true if the user logged in has access to the siteNode sent in.
5278     */

5279    
5280    public boolean getHasUserPageWriteAccess(Integer JavaDoc siteNodeId)
5281    {
5282        boolean hasUserPageWriteAccess = false;
5283        
5284        try
5285        {
5286            Integer JavaDoc protectedSiteNodeVersionId = this.nodeDeliveryController.getProtectedSiteNodeVersionId(getDatabase(), siteNodeId);
5287            if(protectedSiteNodeVersionId == null)
5288            {
5289                logger.info("The page was not protected...");
5290                hasUserPageWriteAccess = true;
5291            }
5292            else
5293            {
5294                logger.info("The page was protected...");
5295                Principal JavaDoc principal = this.getPrincipal();
5296                logger.info("Principal:" + principal);
5297                
5298                if(principal != null)
5299                {
5300                    hasUserPageWriteAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, "SiteNodeVersion.Write", protectedSiteNodeVersionId.toString());
5301                }
5302            }
5303            /*
5304            if(!this.nodeDeliveryController.getIsPageProtected(siteNodeId))
5305            {
5306                logger.info("The page was not protected...");
5307                hasUserPageWriteAccess = true;
5308            }
5309            else
5310            {
5311                logger.info("The page was protected...");
5312                Principal principal = (Principal)this.request.getSession().getAttribute("infogluePrincipal");
5313                logger.info("Principal:" + principal);
5314                if(principal != null)
5315                {
5316                    SiteNodeVersionVO siteNodeVersionVO = this.nodeDeliveryController.getActiveSiteNodeVersionVO(siteNodeId);
5317                    hasUserPageWriteAccess = AccessRightController.getController().getIsPrincipalAuthorized((InfoGluePrincipal)principal, "SiteNodeVersion.Write", siteNodeVersionVO.getId().toString());
5318                    //hasUserPageWriteAccess = ExtranetController.getController().getIsPrincipalAuthorizedForWriteAccess(principal, "SiteNode", "" + siteNodeId, this.nodeDeliveryController);
5319                }
5320            }
5321            */

5322        }
5323        catch(Exception JavaDoc e)
5324        {
5325            logger.error("An error occurred trying to find out if the user had write access to page:" + siteNodeId + ": " + e.getMessage(), e);
5326        }
5327        
5328        return hasUserPageWriteAccess;
5329    }
5330    
5331    /**
5332     * This method returns a list of form elements/attributes based on the schema sent in.
5333     * These consitutes the entire form and a template can then be used to render it in the appropriate technique.
5334     */

5335    
5336    public List JavaDoc getFormAttributes(String JavaDoc contentBindningName, String JavaDoc attributeName)
5337    {
5338        String JavaDoc formDefinition = getContentAttribute(contentBindningName, attributeName, true);
5339        return FormDeliveryController.getFormDeliveryController().getContentTypeAttributes(formDefinition);
5340    }
5341    
5342    /**
5343     * This method returns a list of form elements/attributes based on the schema sent in.
5344     * These consitutes the entire form and a template can then be used to render it in the appropriate technique.
5345     */

5346    
5347    public List JavaDoc getFormAttributes(Integer JavaDoc contentId, String JavaDoc attributeName)
5348    {
5349        String JavaDoc formDefinition = getContentAttribute(contentId, attributeName, true);
5350        return FormDeliveryController.getFormDeliveryController().getContentTypeAttributes(formDefinition);
5351    }
5352    
5353    
5354    /**
5355     * This method returns the full list of steps for a workflow.
5356     */

5357    
5358    public List JavaDoc getWorkflowSteps(String JavaDoc workflowId)
5359    {
5360        List JavaDoc workflowSteps = null;
5361        
5362        try
5363        {
5364            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5365            if(infoGluePrincipal == null)
5366            {
5367                Map JavaDoc arguments = new HashMap JavaDoc();
5368                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5369                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5370
5371                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5372            }
5373            
5374            WorkflowController workflowController = WorkflowController.getController();
5375            logger.info("infoGluePrincipal:" + infoGluePrincipal);
5376            logger.info("workflowId:" + workflowId);
5377            workflowSteps = workflowController.getAllSteps(infoGluePrincipal, new Long JavaDoc(workflowId).longValue());
5378        }
5379        catch(Exception JavaDoc e)
5380        {
5381            logger.warn("An error occurred when trying to get the steps available: " + e.getMessage(), e);
5382        }
5383        
5384        return workflowSteps;
5385    }
5386    
5387    /**
5388     * This method returns the list of hsitorical steps for a workflow instance.
5389     */

5390    
5391    public List JavaDoc getWorkflowHistoricalSteps(String JavaDoc workflowId)
5392    {
5393        List JavaDoc workflowSteps = null;
5394        
5395        try
5396        {
5397            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5398            if(infoGluePrincipal == null)
5399            {
5400                Map JavaDoc arguments = new HashMap JavaDoc();
5401                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5402                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5403                
5404                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5405            }
5406            
5407            WorkflowController workflowController = WorkflowController.getController();
5408            workflowSteps = workflowController.getHistorySteps(infoGluePrincipal, new Long JavaDoc(workflowId).longValue());
5409        }
5410        catch(Exception JavaDoc e)
5411        {
5412            logger.warn("An error occurred when trying to get the steps available: " + e.getMessage(), e);
5413        }
5414        
5415        return workflowSteps;
5416    }
5417    
5418    /**
5419     * This method returns the list of hsitorical steps for a workflow instance.
5420     */

5421    
5422    public List JavaDoc getWorkflowCurrentSteps(String JavaDoc workflowId)
5423    {
5424        List JavaDoc workflowSteps = null;
5425        
5426        try
5427        {
5428            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5429            if(infoGluePrincipal == null)
5430            {
5431                Map JavaDoc arguments = new HashMap JavaDoc();
5432                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5433                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5434
5435                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5436            }
5437
5438            WorkflowController workflowController = WorkflowController.getController();
5439            workflowSteps = workflowController.getCurrentSteps(infoGluePrincipal, new Long JavaDoc(workflowId).longValue());
5440        }
5441        catch(Exception JavaDoc e)
5442        {
5443            logger.warn("An error occurred when trying to get the steps available: " + e.getMessage(), e);
5444        }
5445        
5446        return workflowSteps;
5447    }
5448    
5449    /**
5450     * This method sets a cookie.
5451     *
5452     * @param cookieName
5453     * @param value
5454     * @param domain
5455     * @param path
5456     * @param maxAge
5457     */

5458
5459    public void setCookie(String JavaDoc cookieName, String JavaDoc value, String JavaDoc domain, String JavaDoc path, Integer JavaDoc maxAge)
5460    {
5461        Cookie JavaDoc cookie = new Cookie JavaDoc(cookieName, value);
5462        if(domain != null)
5463            cookie.setDomain(domain);
5464        
5465        if(path != null)
5466            cookie.setPath(path);
5467        
5468        if(maxAge != null)
5469            cookie.setMaxAge(maxAge.intValue());
5470        
5471        this.deliveryContext.getHttpServletResponse().addCookie(cookie);
5472    }
5473    
5474    /**
5475     * This method gets a cookie.
5476     *
5477     * @param cookieName
5478     */

5479
5480    public String JavaDoc getCookie(String JavaDoc cookieName)
5481    {
5482        if(this.request != null)
5483        {
5484            Cookie JavaDoc[] cookies = this.request.getCookies();
5485            if(cookies != null)
5486            {
5487                for(int i=0; i<cookies.length; i++)
5488                {
5489                    Cookie JavaDoc cookie = cookies[i];
5490                    if(cookie.getName().equals(cookieName))
5491                        return cookie.getValue();
5492                }
5493            }
5494        }
5495        
5496        return null;
5497    }
5498    
5499    /**
5500     * This method returns a list of actions the current user are assigned or at least allowed to see.
5501     */

5502    /*
5503    public List getWorkflowActions()
5504    {
5505        List workflowActionVOList = null;
5506        
5507        try
5508        {
5509            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5510            
5511            if(infoGluePrincipal == null)
5512            {
5513                Map arguments = new HashMap();
5514                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5515                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5516
5517                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5518            }
5519           
5520            WorkflowController workflowController = WorkflowController.getController();
5521            workflowActionVOList = workflowController.getCurrentWorkflowActionVOList(infoGluePrincipal);
5522        }
5523        catch(Exception e)
5524        {
5525            logger.warn("An error occurred when trying to get the actions available: " + e.getMessage(), e);
5526        }
5527        
5528        return workflowActionVOList;
5529    }
5530    */

5531    
5532    
5533    /**
5534     * This method returns the properties for a specific workflow instance.
5535     */

5536    /*
5537    public Map getWorkflowProperties(String workflowId)
5538    {
5539        Map properties = null;
5540        
5541        try
5542        {
5543            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5544            if(infoGluePrincipal == null)
5545            {
5546                Map arguments = new HashMap();
5547                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5548                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5549
5550                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5551            }
5552            
5553            WorkflowController workflowController = WorkflowController.getController();
5554            properties = workflowController.getProperties(infoGluePrincipal, new Long(workflowId));
5555        }
5556        catch(Exception e)
5557        {
5558            logger.warn("An error occurred when trying to get the actions available: " + e.getMessage(), e);
5559        }
5560        
5561        return properties;
5562    }
5563    */

5564    
5565    /**
5566     * This method returns the properties for a specific workflow instance.
5567     */

5568    /*
5569    public PropertySet getWorkflowPropertySet(String workflowId)
5570    {
5571        PropertySet propertySet = null;
5572        
5573        try
5574        {
5575            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5576            if(infoGluePrincipal == null)
5577            {
5578                Map arguments = new HashMap();
5579                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5580                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5581
5582                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5583            }
5584            
5585            WorkflowController workflowController = WorkflowController.getController();
5586            propertySet = workflowController.getPropertySet(infoGluePrincipal, new Long(workflowId));
5587        }
5588        catch(Exception e)
5589        {
5590            logger.warn("An error occurred when trying to get the propertySet available: " + e.getMessage(), e);
5591        }
5592        
5593        return propertySet;
5594    }
5595    */

5596    
5597    /**
5598     * This method returns the properties for a specific workflow instance.
5599     */

5600    /*
5601    public void setWorkflowProperty(String workflowId, String propertyKey, String propertyValue)
5602    {
5603        try
5604        {
5605            InfoGluePrincipal infoGluePrincipal = this.getPrincipal();
5606            if(infoGluePrincipal == null)
5607            {
5608                Map arguments = new HashMap();
5609                arguments.put("j_username", CmsPropertyHandler.getAnonymousUser());
5610                arguments.put("j_password", CmsPropertyHandler.getAnonymousPassword());
5611
5612                infoGluePrincipal = (InfoGluePrincipal) ExtranetController.getController().getAuthenticatedPrincipal(arguments);
5613            }
5614            
5615            WorkflowController workflowController = WorkflowController.getController();
5616            workflowController.setProperty(infoGluePrincipal, new Long(workflowId), propertyKey, propertyValue);
5617        }
5618        catch(Exception e)
5619        {
5620            logger.warn("An error occurred when trying to get the actions available: " + e.getMessage(), e);
5621        }
5622    }
5623    */

5624    
5625
5626    /**
5627     * This method supplies a method to get the locale of the language currently in use.
5628     */

5629    
5630    public LanguageVO getLanguage(Integer JavaDoc languageId)
5631    {
5632        LanguageVO language = null;
5633        
5634        try
5635        {
5636            language = LanguageDeliveryController.getLanguageDeliveryController().getLanguageVO(getDatabase(), languageId);
5637        }
5638        catch(Exception JavaDoc e)
5639        {
5640            logger.warn("An error occurred when getting language:" + e.getMessage(), e);
5641        }
5642        
5643        return language;
5644    }
5645
5646    /**
5647     * This method supplies a method to get the locale of the language currently in use.
5648     */

5649    
5650    public LanguageVO getLanguage(String JavaDoc languageCode)
5651    {
5652        LanguageVO language = null;
5653        
5654        try
5655        {
5656            language = LanguageDeliveryController.getLanguageDeliveryController().getLanguageWithCode(getDatabase(), languageCode);
5657        }
5658        catch(Exception JavaDoc e)
5659        {
5660            logger.warn("An error occurred when getting language:" + e.getMessage(), e);
5661        }
5662        
5663        return language;
5664    }
5665
5666    /**
5667     * This method supplies a method to get the locale of the language sent in.
5668     */

5669    
5670    public Locale JavaDoc getLanguageCode(Integer JavaDoc languageId) throws SystemException
5671    {
5672        return LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(getDatabase(), languageId);
5673    }
5674
5675    /**
5676     * This method supplies a method to get the locale of the language currently in use.
5677     */

5678    
5679    public Locale JavaDoc getLocale() throws SystemException
5680    {
5681        return LanguageDeliveryController.getLanguageDeliveryController().getLocaleWithId(getDatabase(), this.languageId);
5682    }
5683
5684
5685    /**
5686     * This method returns the logout url.
5687     * @author Mattias Bogeblad
5688     */

5689    
5690    public String JavaDoc getLogoutURL() throws Exception JavaDoc
5691    {
5692        AuthenticationModule authenticationModule = AuthenticationModule.getAuthenticationModule(this.getDatabase(), null);
5693        return authenticationModule.getLogoutUrl();
5694    }
5695
5696    /**
5697     * This method should be much more sophisticated later and include a check to see if there is a
5698     * digital asset uploaded which is more specialized and can be used to act as serverside logic to the template.
5699     */

5700    
5701    public TemplateController getTemplateController(Integer JavaDoc siteNodeId, Integer JavaDoc languageId, Integer JavaDoc contentId, InfoGluePrincipal infoGluePrincipal, DeliveryContext deliveryContext) throws SystemException, Exception JavaDoc
5702    {
5703        return getTemplateController(siteNodeId, languageId, contentId, this.request, infoGluePrincipal, deliveryContext);
5704    }
5705    
5706    public TemplateController getTemplateController(Integer JavaDoc siteNodeId, Integer JavaDoc languageId, Integer JavaDoc contentId, HttpServletRequest JavaDoc request, InfoGluePrincipal infoGluePrincipal, DeliveryContext deliveryContextt) throws SystemException, Exception JavaDoc
5707    {
5708        TemplateController templateController = null;
5709        templateController = new BasicTemplateController(this.databaseWrapper, infoGluePrincipal);
5710        templateController.setStandardRequestParameters(siteNodeId, languageId, contentId);
5711        templateController.setHttpRequest(request);
5712        templateController.setBrowserBean(this.browserBean);
5713        templateController.setDeliveryControllers(this.nodeDeliveryController, null, this.integrationDeliveryController);
5714        templateController.setDeliveryContext(deliveryContext);
5715        if(isPersistedContext())
5716        {
5717            ((BasicTemplateController) templateController).addToContext(templateLogicContext);
5718            ((BasicTemplateController) templateController).setPersistedContext(true);
5719        }
5720        
5721        String JavaDoc operatingMode = CmsPropertyHandler.getOperatingMode();
5722        String JavaDoc editOnSite = CmsPropertyHandler.getEditOnSite();
5723        boolean isEditOnSightDisabled = templateController.getIsEditOnSightDisabled();
5724        boolean allowEditOnSightAtAll = false;
5725        if(request.getRequestURL().indexOf("!renderDecoratedPage") > -1)
5726            allowEditOnSightAtAll = true;
5727        
5728        if(!isEditOnSightDisabled && operatingMode != null && (operatingMode.equals("0") || operatingMode.equals("1") || operatingMode.equals("2")) && editOnSite != null && editOnSite.equalsIgnoreCase("true"))
5729        {
5730            templateController = new EditOnSiteBasicTemplateController(this.databaseWrapper, infoGluePrincipal);
5731            templateController.setStandardRequestParameters(siteNodeId, languageId, contentId);
5732            templateController.setHttpRequest(request);
5733            templateController.setBrowserBean(browserBean);
5734            templateController.setDeliveryControllers(this.nodeDeliveryController, null, this.integrationDeliveryController);
5735            templateController.setDeliveryContext(deliveryContext);
5736        }
5737
5738        
5739        return templateController;
5740    }
5741
5742    public String JavaDoc decoratePage(String JavaDoc page)
5743    {
5744        return page;
5745    }
5746
5747    /**
5748     * This method adds the neccessairy html to a output for it to be editable.
5749     * It returns an empty string if the delivery engine is in published mode and the showInPublishedMode
5750     * is not set to true. Otherwise it shows the htnl you sent in within a clickable tag.
5751     */

5752    
5753    public String JavaDoc getEditOnSightTag(Integer JavaDoc contentId, String JavaDoc attributeName, String JavaDoc html, boolean showInPublishedMode)
5754    {
5755        return getEditOnSightTag(contentId, this.getLanguageId(), attributeName, html, showInPublishedMode);
5756    }
5757
5758    /**
5759     * This method adds the neccessairy html to a output for it to be editable.
5760     * It returns an empty string if the delivery engine is in published mode and the showInPublishedMode
5761     * is not set to true. Otherwise it shows the htnl you sent in within a clickable tag.
5762     */

5763    
5764    public String JavaDoc getEditOnSightTag(Integer JavaDoc contentId, Integer JavaDoc languageId, String JavaDoc attributeName, String JavaDoc html, boolean showInPublishedMode)
5765    {
5766        if(showInPublishedMode == false && this.getOperatingMode().intValue() == 3)
5767            return "";
5768        else
5769        {
5770            String JavaDoc editOnSiteUrl = CmsPropertyHandler.getEditOnSiteUrl();
5771            String JavaDoc decoratedAttributeValue = "<a HREF=\"#\" onClick=\"window.open('" + editOnSiteUrl + "?contentId=" + contentId + "&languageId=" + languageId + "&attributeName=" + attributeName + "', 'Edit', 'width=500,height=600,left=' + (document.body.clientWidth / 4) + ',top=' + (document.body.clientHeight / 4) + ',toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=no');\">" + html + "</a>";
5772            return decoratedAttributeValue;
5773        }
5774    }
5775
5776    
5777    /**
5778     * This method returns the neccessairy html to assign by klicking on a link.
5779     * @param componentContentId
5780     * @param propertyName
5781     * @param html
5782     * @param showInPublishedMode
5783     * @return
5784     */

5785    public String JavaDoc getAssignPropertyBindingTag(String JavaDoc propertyName, boolean createNew, String JavaDoc html, boolean showInPublishedMode)
5786    {
5787        String JavaDoc result = "";
5788        
5789        try
5790        {
5791            String JavaDoc componentEditorUrl = CmsPropertyHandler.getComponentEditorUrl();
5792    
5793            DecoratedComponentBasedHTMLPageInvoker dec = new DecoratedComponentBasedHTMLPageInvoker();
5794            Collection JavaDoc properties = dec.getComponentProperties(this.getComponentLogic().getInfoGlueComponent().getId(), this, siteNodeId, languageId, this.getComponentLogic().getInfoGlueComponent().getContentId());
5795    
5796            ComponentProperty property = null;
5797            Iterator JavaDoc propertiesIterator = properties.iterator();
5798            while(propertiesIterator.hasNext())
5799            {
5800                ComponentProperty propertyCandidate = (ComponentProperty)propertiesIterator.next();
5801                if(propertyCandidate.getName().equals(propertyName))
5802                    property = propertyCandidate;
5803            }
5804            
5805            String JavaDoc contentId = "-1";
5806            
5807            String JavaDoc createUrl = "";
5808            String JavaDoc assignUrl = "";
5809            
5810            Integer JavaDoc componentId = this.getComponentLogic().getInfoGlueComponent().getId();
5811            Integer JavaDoc repositoryId = this.getSiteNode().getRepositoryId();
5812            
5813            if(property.getVisualizingAction() != null && !property.getVisualizingAction().equals(""))
5814            {
5815                assignUrl = componentEditorUrl + property.getVisualizingAction() + "?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5816            }
5817            else
5818            {
5819                if(property.getEntityClass().equalsIgnoreCase("Content"))
5820                {
5821                    String JavaDoc allowedContentTypeIdParameters = "";
5822
5823                    if(property.getAllowedContentTypeNamesArray() != null && property.getAllowedContentTypeNamesArray().length > 0)
5824                    {
5825                        allowedContentTypeIdParameters = "&" + property.getAllowedContentTypeIdAsUrlEncodedString(getDatabase());
5826                        logger.info("allowedContentTypeIdParameters:" + allowedContentTypeIdParameters);
5827                    }
5828                    
5829                    if(property.getIsMultipleBinding())
5830                        assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showContentTreeForMultipleBinding.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&showSimple=" + getDeliveryContext().getShowSimple();
5831                    else
5832                        assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showContentTree.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&showSimple=" + getDeliveryContext().getShowSimple();
5833                }
5834                else if(property.getEntityClass().equalsIgnoreCase("SiteNode"))
5835                {
5836                    if(property.getIsMultipleBinding())
5837                        assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showStructureTreeForMultipleBinding.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5838                    else
5839                        assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showStructureTree.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5840                }
5841                else if(property.getEntityClass().equalsIgnoreCase("Category"))
5842                {
5843                    if(property.getIsMultipleBinding())
5844                        assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showCategoryTreeForMultipleBinding.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5845                    else
5846                        assignUrl = componentEditorUrl + "ViewSiteNodePageComponents!showCategoryTree.action?repositoryId=" + repositoryId + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5847                }
5848            }
5849
5850            
5851            if(property.getCreateAction() != null && !property.getCreateAction().equals(""))
5852            {
5853                createUrl = componentEditorUrl + property.getCreateAction() + "?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5854            }
5855            else
5856            {
5857                if(property.getVisualizingAction() != null && !property.getVisualizingAction().equals(""))
5858                {
5859                    createUrl = assignUrl;
5860                }
5861                else if(property.getEntityClass().equalsIgnoreCase("Content"))
5862                {
5863                    String JavaDoc allowedContentTypeIdParameters = "";
5864    
5865                    if(property.getAllowedContentTypeNamesArray() != null && property.getAllowedContentTypeNamesArray().length > 0)
5866                    {
5867                        allowedContentTypeIdParameters = "&" + property.getAllowedContentTypeIdAsUrlEncodedString(getDatabase());
5868                        logger.info("allowedContentTypeIdParameters:" + allowedContentTypeIdParameters);
5869                    }
5870    
5871                    String JavaDoc returnAddress = URLEncoder.encode("ViewSiteNodePageComponents!addComponentPropertyBinding.action?siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=-1&entity=Content&entityId=#entityId&componentId=" + componentId + "&propertyName=" + property.getName() + "&path=#path&showSimple=" + getDeliveryContext().getShowSimple() + "", "UTF-8");
5872                    
5873                    if(property.getIsMultipleBinding())
5874                        createUrl = componentEditorUrl + "CreateContentWizardFinish.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&refreshAddress=" + returnAddress + "&showSimple=" + getDeliveryContext().getShowSimple();
5875                    else
5876                        createUrl = componentEditorUrl + "CreateContentWizardFinish.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + allowedContentTypeIdParameters + "&refreshAddress=" + returnAddress + "&showSimple=" + getDeliveryContext().getShowSimple();
5877                }
5878                else if(property.getEntityClass().equalsIgnoreCase("SiteNode"))
5879                {
5880                    if(property.getIsMultipleBinding())
5881                        createUrl = componentEditorUrl + "CreateSiteNodeWizard!input.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5882                    else
5883                        createUrl = componentEditorUrl + "CreateSiteNodeWizard!input.action?repositoryId=" + this.getSiteNode().getRepositoryId() + "&siteNodeId=" + siteNodeId + "&languageId=" + languageId + "&contentId=" + contentId + "&componentId=" + componentId + "&propertyName=" + property.getName() + "&showSimple=" + getDeliveryContext().getShowSimple();
5884                }
5885            }
5886    
5887            if(showInPublishedMode == false && this.getOperatingMode().intValue() == 3)
5888                result = "";
5889            else
5890            {
5891                String JavaDoc editOnSiteUrl = CmsPropertyHandler.getEditOnSiteUrl();
5892
5893                String JavaDoc url = assignUrl;
5894                if(!createNew)
5895                    result = "<a HREF=\"#\" onClick=\"window.open('" + assignUrl + "', 'Edit', 'width=500,height=600,left=' + (document.body.clientWidth / 4) + ',top=' + (document.body.clientHeight / 4) + ',toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=no');\">" + html + "</a>";
5896                else
5897                    result = "<a HREF=\"" + createUrl + "\">" + html + "</a>";
5898                
5899                //String decoratedHTML = "<a HREF=\"#\" onClick=\"window.open('" + url + "', 'Edit', 'width=500,height=600,left=' + (document.body.clientWidth / 4) + ',top=' + (document.body.clientHeight / 4) + ',toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=no');\">" + html + "</a>";
5900
//String decoratedHTML = "<a HREF=\"" + url + "\">" + html + "</a>";
5901
//result = decoratedHTML;
5902
}
5903        }
5904        catch(Exception JavaDoc e)
5905        {
5906            e.printStackTrace();
5907            result = "";
5908        }
5909        
5910        //System.out.println("result:" + result);
5911
return result;
5912    }
5913
5914
5915    public DeliveryContext getDeliveryContext()
5916    {
5917        return deliveryContext;
5918    }
5919    
5920    public void setDeliveryContext(DeliveryContext deliveryContext)
5921    {
5922        this.deliveryContext = deliveryContext;
5923    }
5924    
5925    /**
5926     *
5927     * @return true if this TemplateController will persist the
5928     * templateLogic context in nested parsing.
5929     */

5930    public boolean isPersistedContext()
5931    {
5932        return persistedContext;
5933    }
5934    /**
5935     * If set to true, the current templateLogicContext
5936     * will be passed to any new templateControllers from
5937     * this point. New TemplateControllers are created
5938     * in all nested parsing of the template, like include
5939     * getParsedContentAttribute etc.
5940     *
5941     * @param persistedContext
5942     */

5943    public void setPersistedContext(boolean persistedContext)
5944    {
5945        this.persistedContext = persistedContext;
5946    }
5947    
5948    public boolean getThreatFoldersAsContents()
5949    {
5950        return threatFoldersAsContents;
5951    }
5952    
5953    public void setThreatFoldersAsContents(boolean threatFoldersAsContents)
5954    {
5955        this.threatFoldersAsContents = threatFoldersAsContents;
5956    }
5957
5958    /**
5959     * A method to check if the current pagenode is decorated with EditOnSight
5960     * or not. Checks if it's the BasicTemplateController or the
5961     * EditOnSiteBasicTemplateController which is used as a render.
5962     *
5963     * @return true if the pagenode is rendered with EditOnSight decoration.
5964     */

5965    public boolean getIsDecorated()
5966    {
5967        return ( this instanceof EditOnSiteBasicTemplateController );
5968    }
5969}
Popular Tags