KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > util > CmsPropertyHandler


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.util;
25
26 import java.io.ByteArrayInputStream JavaDoc;
27 import java.io.File JavaDoc;
28 import java.io.FileInputStream JavaDoc;
29 import java.net.InetAddress JavaDoc;
30 import java.util.ArrayList JavaDoc;
31 import java.util.Collection JavaDoc;
32 import java.util.Collections JavaDoc;
33 import java.util.Enumeration JavaDoc;
34 import java.util.HashMap JavaDoc;
35 import java.util.Iterator JavaDoc;
36 import java.util.List JavaDoc;
37 import java.util.Map JavaDoc;
38 import java.util.Properties JavaDoc;
39
40 import org.apache.log4j.Logger;
41 import org.infoglue.cms.controllers.kernel.impl.simple.ServerNodeController;
42 import org.infoglue.cms.entities.management.ServerNodeVO;
43 import org.infoglue.deliver.util.CacheController;
44 import org.infoglue.deliver.util.Timer;
45
46 import com.opensymphony.module.propertyset.PropertySet;
47 import com.opensymphony.module.propertyset.PropertySetManager;
48
49
50
51 /**
52  * CMSPropertyHandler.java
53  * Created on 2002-sep-12
54  *
55  * This class is used to get properties for the system in a transparent way.
56  * The second evolution of this class made it possible for properties to be fetched from the propertyset if there instead. Fallback to file.
57  *
58  * @author Stefan Sik, ss@frovi.com
59  * @author Mattias Bogeblad
60  */

61
62 public class CmsPropertyHandler
63 {
64     private final static Logger logger = Logger.getLogger(CmsPropertyHandler.class.getName());
65
66     private static Properties JavaDoc cachedProperties = null;
67     private static PropertySet propertySet = null;
68
69     private static String JavaDoc serverNodeName = null;
70     
71     private static String JavaDoc globalSettingsServerNodeId= "-1";
72     private static String JavaDoc localSettingsServerNodeId = null;
73     
74     private static String JavaDoc applicationName = null;
75     private static String JavaDoc contextRootPath = null;
76     private static String JavaDoc operatingMode = null;
77     private static File JavaDoc propertyFile = null;
78     
79     public static void setApplicationName(String JavaDoc theApplicationName)
80     {
81         CmsPropertyHandler.applicationName = theApplicationName;
82     }
83
84     public static void setContextRootPath(String JavaDoc contextRootPath)
85     {
86         CmsPropertyHandler.contextRootPath = contextRootPath;
87     }
88
89     public static void setOperatingMode(String JavaDoc operatingMode)
90     {
91         CmsPropertyHandler.operatingMode = operatingMode;
92     }
93
94     public static String JavaDoc getApplicationName()
95     {
96         return applicationName;
97     }
98     
99     public static void setPropertyFile(File JavaDoc aPropertyFile)
100     {
101         propertyFile = aPropertyFile;
102     }
103     
104     /**
105      * This method initializes the parameter hash with values.
106      */

107
108     private static void initializeProperties()
109     {
110         try
111         {
112             Timer timer = new Timer();
113             timer.setActive(false);
114             
115             System.out.println("Initializing properties from file.....");
116             
117             cachedProperties = new Properties JavaDoc();
118             if(propertyFile != null)
119                 cachedProperties.load(new FileInputStream JavaDoc(propertyFile));
120             else
121                 cachedProperties.load(CmsPropertyHandler.class.getResourceAsStream("/" + applicationName + ".properties"));
122             
123             Enumeration JavaDoc enumeration = cachedProperties.keys();
124             while(enumeration.hasMoreElements())
125             {
126                 String JavaDoc key = (String JavaDoc)enumeration.nextElement();
127                 if(key.indexOf("webwork.") > 0)
128                 {
129                     webwork.config.Configuration.set(key, cachedProperties.getProperty(key));
130                 }
131             }
132             
133             timer.printElapsedTime("Initializing properties from file took");
134
135             Map JavaDoc args = new HashMap JavaDoc();
136             args.put("globalKey", "infoglue");
137             try
138             {
139                 propertySet = PropertySetManager.getInstance("jdbc", args);
140                 logger.info("propertySet: " + propertySet);
141             }
142             catch(Exception JavaDoc e)
143             {
144                 propertySet = null;
145                 logger.error("Could not get property set: " + e.getMessage(), e);
146             }
147             
148             timer.printElapsedTime("Initializing properties from jdbc");
149
150             serverNodeName = cachedProperties.getProperty("serverNodeName");
151             
152             if(serverNodeName == null || serverNodeName.length() == 0)
153             {
154                 try
155                 {
156                     InetAddress JavaDoc localhost = InetAddress.getLocalHost();
157                     serverNodeName = localhost.getHostName();
158                 }
159                 catch(Exception JavaDoc e)
160                 {
161                     System.out.println("Error initializing serverNodeName:" + e.getMessage());
162                 }
163             }
164             
165             System.out.println("serverNodeName:" + serverNodeName);
166             
167             initializeLocalServerNodeId();
168             
169             timer.printElapsedTime("Initializing properties from local server jdbc");
170         }
171         catch(Exception JavaDoc e)
172         {
173             cachedProperties = null;
174             logger.error("Error loading properties from file " + "/" + applicationName + ".properties" + ". Reason:" + e.getMessage());
175             e.printStackTrace();
176         }
177         
178     }
179
180     /**
181      * This method gets the local server node id if available.
182      */

183
184     public static void initializeLocalServerNodeId()
185     {
186         try
187         {
188             List JavaDoc serverNodeVOList = ServerNodeController.getController().getServerNodeVOList();
189             Iterator JavaDoc serverNodeVOListIterator = serverNodeVOList.iterator();
190             while(serverNodeVOListIterator.hasNext())
191             {
192                 ServerNodeVO serverNodeVO = (ServerNodeVO)serverNodeVOListIterator.next();
193                 if(serverNodeVO.getName().equalsIgnoreCase(serverNodeName))
194                 {
195                     localSettingsServerNodeId = serverNodeVO.getId().toString();
196                     break;
197                 }
198             }
199         }
200         catch(Exception JavaDoc e)
201         {
202             logger.warn("An error occurred trying to get localSettingsServerNodeId: " + e.getMessage(), e);
203         }
204         
205         System.out.println("localSettingsServerNodeId:" + localSettingsServerNodeId);
206     }
207     
208     /**
209      * This method returns all properties .
210      */

211
212     public static Properties JavaDoc getProperties()
213     {
214         if(cachedProperties == null)
215             initializeProperties();
216                 
217         return cachedProperties;
218     }
219
220  
221     /**
222      * This method returns a propertyValue corresponding to the key supplied.
223      */

224
225     public static String JavaDoc getProperty(String JavaDoc key)
226     {
227         String JavaDoc value;
228         if(cachedProperties == null)
229             initializeProperties();
230         
231         value = cachedProperties.getProperty(key);
232         if (value != null)
233             value = value.trim();
234                 
235         return value;
236     }
237
238
239     /**
240      * This method sets a property during runtime.
241      */

242
243     public static void setProperty(String JavaDoc key, String JavaDoc value)
244     {
245         if(cachedProperties == null)
246             initializeProperties();
247         
248         cachedProperties.setProperty(key, value);
249         
250         CacheController.clearCache("serverNodePropertiesCache");
251     }
252
253     public static String JavaDoc getServerNodeProperty(String JavaDoc key, boolean inherit)
254     {
255         return getServerNodeProperty(null, key, inherit, null);
256     }
257
258     public static String JavaDoc getServerNodeProperty(String JavaDoc key, boolean inherit, String JavaDoc defaultValue)
259     {
260         return getServerNodeProperty(null, key, inherit, defaultValue);
261     }
262
263     /**
264      * This method gets the serverNodeProperty but also fallbacks to the old propertyfile if not found in the propertyset.
265      *
266      * @param key
267      * @param inherit
268      * @return
269      */

270     
271     public static String JavaDoc getServerNodeProperty(String JavaDoc prefix, String JavaDoc key, boolean inherit, String JavaDoc defaultValue)
272     {
273         String JavaDoc value = null;
274         
275         String JavaDoc cacheKey = "" + prefix + "_" + key + "_" + inherit;
276         String JavaDoc cacheName = "serverNodePropertiesCache";
277         logger.info("cacheKey:" + cacheKey);
278         value = (String JavaDoc)CacheController.getCachedObject(cacheName, cacheKey);
279         if(value != null)
280         {
281             return value.trim();
282         }
283         
284         Timer timer = new Timer();
285         logger.info("Getting jdbc-property:" + cacheKey);
286         if(propertySet != null)
287         {
288             if(localSettingsServerNodeId != null)
289             {
290                 if(prefix != null)
291                 {
292                     value = propertySet.getString("serverNode_" + localSettingsServerNodeId + "_" + prefix + "_" + key);
293                     //System.out.println("Local value: " + value);
294
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
295                     {
296                         value = propertySet.getString("serverNode_" + globalSettingsServerNodeId + "_" + prefix + "_" + key);
297                         //System.out.println("Global value: " + value);
298
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
299                         {
300                             value = propertySet.getString("serverNode_" + globalSettingsServerNodeId + "_" + key);
301                             //System.out.println("Global value: " + value);
302
}
303     
304                     }
305                 }
306                 else
307                 {
308                     value = propertySet.getString("serverNode_" + localSettingsServerNodeId + "_" + key);
309                     //System.out.println("Local value: " + value);
310
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
311                     {
312                         value = propertySet.getString("serverNode_" + globalSettingsServerNodeId + "_" + key);
313                         //System.out.println("Global value: " + value);
314
}
315                 }
316             }
317             else
318             {
319                 if(prefix != null)
320                 {
321                     value = propertySet.getString("serverNode_" + globalSettingsServerNodeId + "_" + prefix + "_" + key);
322                     //System.out.println("Global value immediately: " + value);
323
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
324                     {
325                         value = propertySet.getString("serverNode_" + globalSettingsServerNodeId + "_" + key);
326                         //System.out.println("Global value: " + value);
327
}
328                 }
329                 else
330                 {
331                     value = propertySet.getString("serverNode_" + globalSettingsServerNodeId + "_" + key);
332                     //System.out.println("Global value immediately: " + value);
333
}
334             }
335         }
336         
337         if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
338         {
339             value = getProperty(key);
340             //System.out.println("Property value: " + value);
341
}
342
343         if((value == null || value.indexOf(key) > -1) && defaultValue != null)
344             value = defaultValue;
345         
346         if(value != null)
347             value = value.trim();
348         
349         CacheController.cacheObject(cacheName, cacheKey, value);
350         
351         logger.info("Getting property " + cacheKey + " took:" + timer.getElapsedTime());
352         
353         return value;
354     }
355
356     
357     /**
358      * This method gets the serverNodeDataProperty.
359      *
360      * @param key
361      * @param inherit
362      * @return
363      */

364     
365     public static String JavaDoc getServerNodeDataProperty(String JavaDoc prefix, String JavaDoc key, boolean inherit, String JavaDoc defaultValue)
366     {
367         String JavaDoc value = null;
368         
369         String JavaDoc cacheKey = "" + prefix + "_" + key + "_" + inherit;
370         String JavaDoc cacheName = "serverNodePropertiesCache";
371         logger.info("cacheKey:" + cacheKey);
372         value = (String JavaDoc)CacheController.getCachedObject(cacheName, cacheKey);
373         if(value != null)
374         {
375             return value;
376         }
377         
378         Timer timer = new Timer();
379
380         logger.info("Getting jdbc-property:" + cacheKey);
381         if(localSettingsServerNodeId != null)
382         {
383             if(prefix != null)
384             {
385                 value = getDataPropertyValue("serverNode_" + localSettingsServerNodeId + "_" + prefix + "_" + key);
386                 //System.out.println("Local value: " + value);
387
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
388                 {
389                     value = getDataPropertyValue("serverNode_" + globalSettingsServerNodeId + "_" + prefix + "_" + key);
390                     //System.out.println("Global value: " + value);
391
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
392                     {
393                         value = getDataPropertyValue("serverNode_" + globalSettingsServerNodeId + "_" + key);
394                         //System.out.println("Global value: " + value);
395
}
396
397                 }
398             }
399             else
400             {
401                 value = getDataPropertyValue("serverNode_" + localSettingsServerNodeId + "_" + key);
402                 //System.out.println("Local value: " + value);
403
if(value == null || value.equals("") || value.equalsIgnoreCase("inherit") && inherit)
404                 {
405                     value = getDataPropertyValue("serverNode_" + globalSettingsServerNodeId + "_" + key);
406                     //System.out.println("Global value: " + value);
407
}
408             }
409         }
410         else
411         {
412             if(prefix != null)
413             {
414                 value = getDataPropertyValue("serverNode_" + globalSettingsServerNodeId + "_" + prefix + "_" + key);
415                 //System.out.println("Global value immediately: " + value);
416
}
417             else
418             {
419                 value = getDataPropertyValue("serverNode_" + globalSettingsServerNodeId + "_" + key);
420                 //System.out.println("Global value immediately: " + value);
421
}
422         }
423         
424         if(value == null && defaultValue != null)
425             value = defaultValue;
426         
427         CacheController.cacheObject(cacheName, cacheKey, value);
428         
429         logger.info("Getting property " + cacheKey + " took:" + timer.getElapsedTime());
430         
431         return value;
432     }
433     
434     public static String JavaDoc getDataPropertyValue(String JavaDoc fullKey)
435     {
436         String JavaDoc result = null;
437         
438         try
439         {
440             byte[] valueBytes = propertySet.getData(fullKey);
441         
442             result = (valueBytes != null ? new String JavaDoc(valueBytes, "utf-8") : "");
443         }
444         catch(Exception JavaDoc e)
445         {
446             e.printStackTrace();
447         }
448         
449         return result;
450     }
451     
452     public static String JavaDoc getContextRootPath()
453     {
454         return contextRootPath; //getProperty("contextRootPath"); Concurrency issues...
455
}
456
457     public static String JavaDoc getOperatingMode()
458     {
459         if(operatingMode == null)
460             return getProperty("operatingMode");
461         else
462             return operatingMode; //getProperty("operatingMode"); Concurrency issues...
463
}
464     
465     //TODO - refresh if changed....
466
//private static String inputCharacterEncoding = null;
467
public static String JavaDoc getInputCharacterEncoding(String JavaDoc defaultEncoding)
468     {
469         //if(inputCharacterEncoding == null)
470
//{
471
String JavaDoc applicationName = CmsPropertyHandler.getApplicationName();
472             String JavaDoc newInputCharacterEncoding = CmsPropertyHandler.getServerNodeProperty("inputCharacterEncoding", true, defaultEncoding);
473             if(!applicationName.equalsIgnoreCase("cms"))
474                 newInputCharacterEncoding = CmsPropertyHandler.getServerNodeProperty("deliver", "inputCharacterEncoding", true, defaultEncoding);
475
476             //inputCharacterEncoding = newInputCharacterEncoding;
477
//}
478
return newInputCharacterEncoding;
479         //return inputCharacterEncoding;
480
}
481     
482     public static String JavaDoc getUp2dateUrl()
483     {
484         return getProperty("up2dateUrl");
485     }
486
487     public static String JavaDoc getURLComposerClass()
488     {
489         return getProperty("URLComposerClass");
490     }
491
492     public static String JavaDoc getMaxClients()
493     {
494         return getProperty("maxClients");
495     }
496
497     public static String JavaDoc getAdministratorUserName()
498     {
499         return getProperty("administratorUserName");
500     }
501
502     public static String JavaDoc getAdministratorPassword()
503     {
504         return getProperty("administratorPassword");
505     }
506
507     public static String JavaDoc getAdministratorEmail()
508     {
509         return getProperty("administratorEmail");
510     }
511
512     public static String JavaDoc getDbRelease()
513     {
514         return getProperty("dbRelease");
515     }
516
517     public static String JavaDoc getDbUser()
518     {
519         return getProperty("dbUser");
520     }
521
522     public static String JavaDoc getDbPassword()
523     {
524         return getProperty("dbPassword");
525     }
526
527     public static String JavaDoc getMasterServer()
528     {
529         return getProperty("masterServer");
530     }
531     public static String JavaDoc getSlaveServer()
532     {
533         return getProperty("slaveServer");
534     }
535
536     public static String JavaDoc getBuildName()
537     {
538         return getProperty("buildName");
539     }
540     public static String JavaDoc getAdminToolsPath()
541     {
542         return getProperty("adminToolsPath");
543     }
544     public static String JavaDoc getDbScriptPath()
545     {
546         return getProperty("dbScriptPath");
547     }
548
549     public static String JavaDoc getDigitalAssetUploadPath()
550     {
551         return getServerNodeProperty("digitalAssetUploadPath", true);
552     }
553     
554     public static String JavaDoc getExtranetCookieTimeout()
555     {
556         return getServerNodeProperty("extranetCookieTimeout", true, "1800");
557     }
558
559     public static String JavaDoc getWebServicesBaseUrl()
560     {
561         return getServerNodeProperty("webServicesBaseUrl", true);
562     }
563
564     public static String JavaDoc getPublicationThreadDelay()
565     {
566         return getServerNodeProperty("publicationThreadDelay", true, "5000");
567     }
568
569     public static String JavaDoc getPathsToRecacheOnPublishing()
570     {
571         return getServerNodeProperty("pathsToRecacheOnPublishing", true);
572     }
573
574     public static String JavaDoc getDisableTemplateDebug()
575     {
576         return getServerNodeProperty("disableTemplateDebug", true, "false");
577     }
578
579     public static String JavaDoc getTree()
580     {
581         return getServerNodeProperty("tree", true, "html");
582     }
583
584     public static String JavaDoc getTreeMode()
585     {
586         return getServerNodeProperty("treemode", true, "dynamic");
587     }
588
589     public static String JavaDoc getPreviewDeliveryUrl()
590     {
591         return getServerNodeProperty("previewDeliveryUrl", true);
592     }
593
594     public static String JavaDoc getStagingDeliveryUrl()
595     {
596         return getServerNodeProperty("stagingDeliveryUrl", true);
597     }
598
599     public static String JavaDoc getEditionPageSize()
600     {
601         return getServerNodeProperty("edition.pageSize", true, "10");
602     }
603     
604     public static String JavaDoc getContentTreeSort()
605     {
606         return getServerNodeProperty("content.tree.sort", true, "name");
607     }
608
609     public static String JavaDoc getStructureTreeSort()
610     {
611         return getServerNodeProperty("structure.tree.sort", true, "name");
612     }
613
614     public static String JavaDoc getStructureTreeIsHiddenProperty()
615     {
616         return getServerNodeProperty("structure.tree.isHidden", true);
617     }
618
619     public static String JavaDoc getDisableEmptyUrls()
620     {
621         return getServerNodeProperty("disableEmptyUrls", true, "yes");
622     }
623
624     public static String JavaDoc getCacheUpdateAction()
625     {
626         return getServerNodeProperty("cacheUpdateAction", true, "UpdateCache.action");
627     }
628
629     public static String JavaDoc getLogPath()
630     {
631         return getServerNodeProperty("logPath", true);
632     }
633
634     public static String JavaDoc getLogTransactions()
635     {
636         return getServerNodeProperty("logTransactions", true, "false");
637     }
638     
639     public static String JavaDoc getEnableExtranetCookies()
640     {
641         return getServerNodeProperty("enableExtranetCookies", true, "false");
642     }
643     
644     public static String JavaDoc getUseAlternativeBrowserLanguageCheck()
645     {
646         return getServerNodeProperty("useAlternativeBrowserLanguageCheck", true, "false");
647     }
648     
649     public static String JavaDoc getCaseSensitiveRedirects()
650     {
651         return getServerNodeProperty("caseSensitiveRedirects", true, "false");
652     }
653     
654     public static String JavaDoc getUseDNSNameInURI()
655     {
656         return getServerNodeProperty("useDNSNameInURI", true, "false");
657     }
658     
659     public static String JavaDoc getWysiwygEditor()
660     {
661         return getServerNodeProperty("wysiwygEditor", true, "FCKEditor");
662     }
663
664     public static String JavaDoc getProtectContentTypes()
665     {
666         return getServerNodeProperty("protectContentTypes", true, "false");
667     }
668
669     public static String JavaDoc getProtectWorkflows()
670     {
671         return getServerNodeProperty("protectWorkflows", true, "false");
672     }
673
674     public static String JavaDoc getProtectCategories()
675     {
676         return getServerNodeProperty("protectCategories", true, "false");
677     }
678
679     public static String JavaDoc getMaxRows()
680     {
681         return getServerNodeProperty("maxRows", true, "100");
682     }
683     
684     public static String JavaDoc getShowContentVersionFirst()
685     {
686         return getServerNodeProperty("showContentVersionFirst", true, "true");
687     }
688     
689     public static String JavaDoc getShowComponentsFirst()
690     {
691         return getServerNodeProperty("showComponentsFirst", true, "true");
692     }
693     
694     public static String JavaDoc getShowAllWorkflows()
695     {
696         return getServerNodeProperty("showAllWorkflows", true, "true");
697     }
698     
699     public static String JavaDoc getIsPageCacheOn()
700     {
701         return getServerNodeProperty("isPageCacheOn", true, "true");
702     }
703
704     public static String JavaDoc getEditOnSite()
705     {
706         return getServerNodeProperty("editOnSite", true, "true");
707     }
708
709     public static String JavaDoc getUseSelectivePageCacheUpdate()
710     {
711         return getServerNodeProperty("useSelectivePageCacheUpdate", true, "true");
712     }
713
714     public static String JavaDoc getExpireCacheAutomatically()
715     {
716         return getServerNodeProperty("expireCacheAutomatically", true, "false");
717     }
718
719     public static String JavaDoc getCacheExpireInterval()
720     {
721         return getServerNodeProperty("cacheExpireInterval", true, "1800");
722     }
723
724     public static String JavaDoc getDeliverRequestTimeout()
725     {
726         return getServerNodeProperty("deliverRequestTimeout", true, "60000");
727     }
728     
729     public static String JavaDoc getSessionTimeout()
730     {
731         return getServerNodeProperty("session.timeout", true, "1800");
732     }
733
734     public static String JavaDoc getCompressPageCache()
735     {
736         return getServerNodeProperty("compressPageCache", true, "true");
737     }
738
739     public static String JavaDoc getCompressPageResponse()
740     {
741         return getServerNodeProperty("compressPageResponse", true, "false");
742     }
743
744     public static String JavaDoc getSiteNodesToRecacheOnPublishing()
745     {
746         return getServerNodeProperty("siteNodesToRecacheOnPublishing", true);
747     }
748
749     public static String JavaDoc getRecachePublishingMethod()
750     {
751         return getServerNodeProperty("recachePublishingMethod", true);
752     }
753
754     public static String JavaDoc getRecacheUrl()
755     {
756         return getServerNodeProperty("recacheUrl", true);
757     }
758
759     public static String JavaDoc getUseUpdateSecurity()
760     {
761         return getServerNodeProperty("useUpdateSecurity", true, "true");
762     }
763     
764     public static String JavaDoc getAllowedAdminIP()
765     {
766         return getServerNodeProperty("allowedAdminIP", true);
767     }
768
769     public static String JavaDoc getPageKey()
770     {
771         return getServerNodeProperty("pageKey", true);
772     }
773     
774     public static String JavaDoc getCmsFullBaseUrl()
775     {
776         return getServerNodeProperty("cmsFullBaseUrl", true);
777     }
778
779     public static String JavaDoc getCmsBaseUrl()
780     {
781         return getServerNodeProperty("cmsBaseUrl", true);
782     }
783
784     public static String JavaDoc getComponentEditorUrl()
785     {
786         return getServerNodeProperty("componentEditorUrl", true);
787     }
788
789     public static String JavaDoc getComponentRendererUrl()
790     {
791         return getServerNodeProperty("componentRendererUrl", true);
792     }
793
794     public static String JavaDoc getComponentRendererAction()
795     {
796         return getServerNodeProperty("componentRendererAction", true);
797     }
798
799     public static String JavaDoc getEditOnSiteUrl()
800     {
801         return getServerNodeProperty("editOnSiteUrl", true);
802     }
803
804     public static String JavaDoc getUseFreeMarker()
805     {
806         return getServerNodeProperty("useFreeMarker", true, "false");
807     }
808
809     public static String JavaDoc getWebServerAddress()
810     {
811         return getServerNodeProperty("webServerAddress", true);
812     }
813
814     public static String JavaDoc getApplicationBaseAction()
815     {
816         return getServerNodeProperty("applicationBaseAction", true);
817     }
818
819     public static String JavaDoc getDigitalAssetBaseUrl()
820     {
821         return getServerNodeProperty("digitalAssetBaseUrl", true);
822     }
823
824     public static String JavaDoc getImagesBaseUrl()
825     {
826         return getServerNodeProperty("imagesBaseUrl", true);
827     }
828
829     public static String JavaDoc getDigitalAssetPath()
830     {
831         return getServerNodeProperty("digitalAssetPath", true);
832     }
833
834     public static String JavaDoc getEnableNiceURI()
835     {
836         return getServerNodeProperty("enableNiceURI", true, "true");
837     }
838
839     public static String JavaDoc getNiceURIEncoding()
840     {
841         return getServerNodeProperty("niceURIEncoding", true, "UTF-8");
842     }
843
844     public static String JavaDoc getNiceURIAttributeName()
845     {
846         return getServerNodeProperty("niceURIAttributeName", true, "NiceURIName");
847     }
848
849     public static String JavaDoc getRequestArgumentDelimiter()
850     {
851         return getServerNodeProperty("requestArgumentDelimiter", true, "&");
852     }
853
854     public static String JavaDoc getErrorUrl()
855     {
856         return getServerNodeProperty("errorUrl", true);
857     }
858
859     public static String JavaDoc getErrorBusyUrl()
860     {
861         return getServerNodeProperty("errorBusyUrl", true);
862     }
863
864     public static String JavaDoc getExternalThumbnailGeneration()
865     {
866         return getServerNodeProperty("externalThumbnailGeneration", true);
867     }
868
869     public static String JavaDoc getURIEncoding()
870     {
871         return getServerNodeProperty("URIEncoding", true, "UTF-8");
872     }
873
874     public static String JavaDoc getWorkflowEncoding()
875     {
876         return getServerNodeProperty("workflowEncoding", true, "UTF-8");
877     }
878
879     public static String JavaDoc getFormsEncoding()
880     {
881         return getServerNodeProperty("formsEncoding", true, "UTF-8");
882     }
883
884     public static String JavaDoc getUseShortTableNames()
885     {
886         return getServerNodeProperty("useShortTableNames", true, "false");
887     }
888
889     public static String JavaDoc getLogDatabaseMessages()
890     {
891         return getServerNodeProperty("logDatabaseMessages", true, "false");
892     }
893
894     public static String JavaDoc getStatisticsEnabled()
895     {
896         return getServerNodeProperty("statistics.enabled", true, "false");
897     }
898
899     public static String JavaDoc getStatisticsLogPath()
900     {
901         return getServerNodeProperty("statisticsLogPath", true);
902     }
903
904     public static String JavaDoc getStatisticsLogOneFilePerDay()
905     {
906         return getServerNodeProperty("statisticsLogOneFilePerDay", true, "false");
907     }
908
909     public static String JavaDoc getStatisticsLogger()
910     {
911         return getServerNodeProperty("statisticsLogger", true, "W3CExtendedLogger");
912     }
913
914     public static String JavaDoc getEnablePortal()
915     {
916         return getServerNodeProperty("enablePortal", true, "true");
917     }
918
919     public static String JavaDoc getPortletBase()
920     {
921         return getServerNodeProperty("portletBase", true);
922     }
923
924     public static String JavaDoc getMailSmtpHost()
925     {
926         return getServerNodeProperty("mail.smtp.host", true);
927     }
928
929     public static String JavaDoc getMailSmtpAuth()
930     {
931         return getServerNodeProperty("mail.smtp.auth", true);
932     }
933
934     public static String JavaDoc getMailSmtpUser()
935     {
936         return getServerNodeProperty("mail.smtp.user", true);
937     }
938
939     public static String JavaDoc getMailSmtpPassword()
940     {
941         return getServerNodeProperty("mail.smtp.password", true);
942     }
943
944     public static String JavaDoc getMailContentType()
945     {
946         return getServerNodeProperty("mail.contentType", true, "text/html");
947     }
948     
949     public static String JavaDoc getSystemEmailSender()
950     {
951         return getServerNodeProperty("systemEmailSender", true);
952     }
953
954     public static String JavaDoc getWarningEmailReceiver()
955     {
956         return getServerNodeProperty("warningEmailReceiver", true);
957     }
958
959     public static String JavaDoc getExportFormat()
960     {
961         return getServerNodeProperty("exportFormat", true, "1");
962     }
963
964     public static String JavaDoc getHelpUrl()
965     {
966         return getServerNodeProperty("helpUrl", true);
967     }
968
969     public static String JavaDoc getProtectDeliverWorking()
970     {
971         return getServerNodeProperty("protectDeliverWorking", true, "false");
972     }
973
974     public static String JavaDoc getProtectDeliverPreview()
975     {
976         return getServerNodeProperty("protectDeliverPreview", true, "false");
977     }
978
979     public static String JavaDoc getPreferredLanguageCode(String JavaDoc userName)
980     {
981         return propertySet.getString("principal_" + userName + "_languageCode");
982     }
983
984     public static String JavaDoc getPreferredToolId(String JavaDoc userName)
985     {
986         return propertySet.getString("principal_" + userName + "_defaultToolId");
987     }
988
989     public static List JavaDoc getInternalDeliveryUrls()
990     {
991         List JavaDoc urls = new ArrayList JavaDoc();
992         
993         String JavaDoc internalDeliverUrlsString = CmsPropertyHandler.getServerNodeDataProperty(null, "internalDeliveryUrls", true, null);
994         //System.out.println("internalDeliverUrlsString:" + internalDeliverUrlsString);
995
if(internalDeliverUrlsString != null && !internalDeliverUrlsString.equals(""))
996         {
997             try
998             {
999                 Properties JavaDoc properties = new Properties JavaDoc();
1000                properties.load(new ByteArrayInputStream JavaDoc(internalDeliverUrlsString.getBytes("UTF-8")));
1001
1002                int i = 0;
1003                String JavaDoc deliverUrl = null;
1004                while((deliverUrl = properties.getProperty("" + i)) != null)
1005                {
1006                    urls.add(deliverUrl);
1007                    i++;
1008                }
1009
1010            }
1011            catch(Exception JavaDoc e)
1012            {
1013                logger.error("Error loading properties from string. Reason:" + e.getMessage());
1014                e.printStackTrace();
1015            }
1016        }
1017        else
1018        {
1019            int i = 0;
1020            String JavaDoc deliverUrl = null;
1021            while((deliverUrl = CmsPropertyHandler.getProperty("internalDeliverUrl." + i)) != null)
1022            {
1023                urls.add(deliverUrl);
1024                i++;
1025            }
1026        }
1027
1028        return urls;
1029    }
1030
1031    public static List JavaDoc getPublicDeliveryUrls()
1032    {
1033        List JavaDoc urls = new ArrayList JavaDoc();
1034        
1035        String JavaDoc publicDeliverUrlString = CmsPropertyHandler.getServerNodeDataProperty(null, "publicDeliveryUrls", true, null);
1036        //System.out.println("publicDeliverUrlString:" + publicDeliverUrlString);
1037
if(publicDeliverUrlString != null && !publicDeliverUrlString.equals(""))
1038        {
1039            try
1040            {
1041                Properties JavaDoc properties = new Properties JavaDoc();
1042                properties.load(new ByteArrayInputStream JavaDoc(publicDeliverUrlString.getBytes("UTF-8")));
1043
1044                int i = 0;
1045                String JavaDoc deliverUrl = null;
1046                while((deliverUrl = properties.getProperty("" + i)) != null)
1047                {
1048                    urls.add(deliverUrl);
1049                    i++;
1050                }
1051
1052            }
1053            catch(Exception JavaDoc e)
1054            {
1055                logger.error("Error loading properties from string. Reason:" + e.getMessage());
1056                e.printStackTrace();
1057            }
1058        }
1059        else
1060        {
1061            int i = 0;
1062            String JavaDoc deliverUrl = null;
1063            while((deliverUrl = CmsPropertyHandler.getProperty("publicDeliverUrl." + i)) != null)
1064            {
1065                urls.add(deliverUrl);
1066                i++;
1067            }
1068        }
1069        
1070        return urls;
1071    }
1072    
1073    public static String JavaDoc getPropertySetValue(String JavaDoc key)
1074    {
1075        String JavaDoc value = null;
1076        
1077        String JavaDoc cacheKey = "" + key;
1078        String JavaDoc cacheName = "propertySetCache";
1079        //logger.info("cacheKey:" + cacheKey);
1080
value = (String JavaDoc)CacheController.getCachedObject(cacheName, cacheKey);
1081        if(value != null)
1082        {
1083            logger.info("Returning property " + cacheKey + " value " + value);
1084            return value;
1085        }
1086        
1087        value = propertySet.getString(key);
1088        logger.info("propertySetCache did not have value... refetched:" + value);
1089        
1090        CacheController.cacheObject(cacheName, cacheKey, value);
1091        
1092        return value;
1093    }
1094
1095    public static String JavaDoc getAnonymousPassword()
1096    {
1097        String JavaDoc password = "anonymous";
1098        //String specifiedPassword = getProperty("security.anonymous.password");
1099
String JavaDoc specifiedPassword = getServerNodeProperty("deliver", "security.anonymous.password", true, "anonymous");
1100        if(specifiedPassword != null && !specifiedPassword.equalsIgnoreCase("") && specifiedPassword.indexOf("security.anonymous.password") == -1)
1101            password = specifiedPassword;
1102        
1103        //System.out.println("password:" + password);
1104

1105        return password;
1106    }
1107
1108    public static String JavaDoc getAnonymousUser()
1109    {
1110        String JavaDoc userName = "anonymous";
1111        //String specifiedUserName = getProperty("security.anonymous.username");
1112
String JavaDoc specifiedUserName = getServerNodeProperty("deliver", "security.anonymous.username", true, "anonymous");
1113        if(specifiedUserName != null && !specifiedUserName.equalsIgnoreCase("") && specifiedUserName.indexOf("security.anonymous.username") == -1)
1114            userName = specifiedUserName;
1115        
1116        //System.out.println("userName:" + userName);
1117

1118        return userName;
1119    }
1120
1121}
1122
Popular Tags