KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mvnforum > MVNForumConfig


1 /*
2  * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/MVNForumConfig.java,v 1.97 2006/04/14 17:05:25 minhnn Exp $
3  * $Author: minhnn $
4  * $Revision: 1.97 $
5  * $Date: 2006/04/14 17:05:25 $
6  *
7  * ====================================================================
8  *
9  * Copyright (C) 2002-2006 by MyVietnam.net
10  *
11  * All copyright notices regarding mvnForum MUST remain
12  * intact in the scripts and in the outputted HTML.
13  * The "powered by" text/logo with a link back to
14  * http://www.mvnForum.com and http://www.MyVietnam.net in
15  * the footer of the pages MUST remain visible when the pages
16  * are viewed on the internet or intranet.
17  *
18  * This program is free software; you can redistribute it and/or modify
19  * it under the terms of the GNU General Public License as published by
20  * the Free Software Foundation; either version 2 of the License, or
21  * any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31  *
32  * Support can be obtained from support forums at:
33  * http://www.mvnForum.com/mvnforum/index
34  *
35  * Correspondence and Marketing Questions can be sent to:
36  * info at MyVietnam net
37  *
38  * @author: Minh Nguyen
39  * @author: Mai Nguyen
40  * @author: Igor Manic
41  */

42 package com.mvnforum;
43
44 import java.io.*;
45 import java.util.Locale JavaDoc;
46
47 import com.mvnforum.db.DAOFactory;
48 import freemarker.cache.FileTemplateLoader;
49 import freemarker.template.Configuration;
50 import net.myvietnam.mvncore.configuration.DOM4JConfiguration;
51 import net.myvietnam.mvncore.db.DBUtils;
52 import net.myvietnam.mvncore.exception.*;
53 import net.myvietnam.mvncore.info.DatabaseInfo;
54 import net.myvietnam.mvncore.security.FloodControl;
55 import net.myvietnam.mvncore.util.*;
56 import org.apache.commons.logging.Log;
57 import org.apache.commons.logging.LogFactory;
58 import org.apache.lucene.store.Directory;
59 import org.apache.lucene.store.FSDirectory;
60
61 public final class MVNForumConfig {
62
63     private static Log log = LogFactory.getLog(MVNForumConfig.class);
64
65     private MVNForumConfig() {
66     }
67
68     private static final String JavaDoc OPTION_FILE_NAME = "mvnforum.xml";
69
70     private static boolean m_shouldRun = true;
71     public static boolean isShouldRun() {
72         return m_shouldRun;
73     }
74
75     private static String JavaDoc m_reason = "Normal System";
76     public static String JavaDoc getReason() {
77         return m_reason;
78     }
79
80     private static boolean m_showUserArea = true;
81     public static boolean getShouldShowUserArea() {
82         return m_showUserArea;
83     }
84     public static void setShouldShowUserArea(boolean showUserArea) {
85         m_showUserArea = showUserArea;
86     }
87
88     /**
89      * This method could be use to stop run the forum in some condition.
90      * Some use could be a page that immediately stop the forum for security.
91      * Other usage is to check to run on some environment such as Servlet 2.3 or later
92      *
93      * @param shouldRun boolean the new shouldRun
94      * @param reason String the reason of the action, this reason will
95      * be shown in the error page
96      */

97     public static void setShouldRun(boolean shouldRun, String JavaDoc reason) {
98         m_shouldRun = shouldRun;
99         m_reason = reason;
100     }
101
102     private static boolean m_guestUserInDatabase = false;
103     public static boolean isGuestUserInDatabase() {
104         return m_guestUserInDatabase;
105     }
106
107     private static String JavaDoc tempDir = "";
108     private static String JavaDoc searchPostIndexDir = "";
109     private static String JavaDoc searchCompanyIndexDir = "";
110     private static String JavaDoc searchMemberIndexDir = "";
111     private static String JavaDoc attachmentDir = "";
112     private static String JavaDoc pmAttachmentDir = "";
113     private static String JavaDoc backupDir = "";
114     private static String JavaDoc templateDir = "";
115     private static String JavaDoc logDir = "";
116     private static String JavaDoc avatarDir = "";
117
118     private static String JavaDoc LOG_FILE= "";
119
120     private static void setMVNForumHome(String JavaDoc home) {
121         // now check the read/write permission by writing a temp file
122
try {
123             // always create a dir, if the dir already exitsted, nothing happen
124
FileUtil.createDirs(home, true);
125
126             String JavaDoc tempFilename = home + File.separatorChar + "mvnforum_tempfile.tmp";
127             File tempFile = new File(tempFilename);
128             if (log.isDebugEnabled()) {
129                 log.debug("Temp file = " + tempFilename);
130                 log.debug("Absolute filename of temp file = " + tempFile.getAbsolutePath());
131             }
132
133             FileOutputStream fos = new FileOutputStream(tempFilename);
134             fos.write(tempFilename.getBytes());
135             fos.close();
136
137             tempFile.delete();
138
139             // now create the dirs if not exitst
140
tempDir = MVNFORUM_HOME + File.separatorChar + "temp";
141             FileUtil.createDirs(tempDir, true);
142
143             searchPostIndexDir = MVNFORUM_HOME + File.separatorChar + "search" + File.separatorChar + "post";
144             FileUtil.createDirs(searchPostIndexDir, true);
145
146             searchCompanyIndexDir = MVNFORUM_HOME + File.separatorChar + "search" + File.separatorChar + "company";
147             FileUtil.createDirs(searchCompanyIndexDir, true);
148
149             searchMemberIndexDir = MVNFORUM_HOME + File.separatorChar + "search" + File.separatorChar + "member";
150             FileUtil.createDirs(searchMemberIndexDir, true);
151
152             attachmentDir = MVNFORUM_HOME + File.separatorChar + "attachment";
153             FileUtil.createDirs(attachmentDir, true);
154
155             pmAttachmentDir = MVNFORUM_HOME + File.separatorChar + "pm_attachment";
156             FileUtil.createDirs(pmAttachmentDir, true);
157
158             backupDir = MVNFORUM_HOME + File.separatorChar + "backup";
159             FileUtil.createDirs(backupDir, true);
160
161             // this dir is created as a recommended folder to store the log files
162
logDir = MVNFORUM_HOME + File.separatorChar + "log";
163             FileUtil.createDirs(logDir, true);
164
165             avatarDir = MVNFORUM_HOME + File.separatorChar + "memberavatars";
166             FileUtil.createDirs(avatarDir, true);
167
168             // this dir is created as a recommended folder to store the template files
169
templateDir = MVNFORUM_HOME + File.separatorChar + "template";
170             FileUtil.createDirs(templateDir, true);
171
172             // now check the database
173
DatabaseInfo databaseInfo = new DatabaseInfo();
174             if (databaseInfo.getErrorMessage() != null) {
175                 log.fatal("Cannot get database connection. Please correct it first.");
176                 m_shouldRun = false;
177                 m_reason = "Check your database configuration. Detail : " + databaseInfo.getErrorMessage();
178             } else if (DAOFactory.getMemberDAO().getNumberOfMembers() == 0) { // check if no member
179
log.fatal("There are no members in database. Please correct it first.");
180                 m_shouldRun = false;
181                 m_reason = "There are no members in database.";
182             } else if (databaseInfo.getDatabaseUrl().toLowerCase().startsWith("jdbc:odbc:")) {
183                 log.fatal("Does not support JDBC/ODBC driver. Please use other drivers.");
184                 m_shouldRun = false;
185                 m_reason = "Does not support JDBC/ODBC driver. Please use other drivers.";
186             }
187             // call this method will print the database type to logger with level INFO
188
DBUtils.getDatabaseType();
189         } catch (IOException ex) {
190             log.fatal("Cannot setup the mvnForumHome folder. Please correct it first.", ex);
191             m_shouldRun = false;
192             m_reason = "Check your mvnForumHome. Detail : " + ex.getMessage();
193         } catch (DatabaseException dbe) {
194             log.fatal("Error while access database. Please correct it first.", dbe);
195             m_shouldRun = false;
196             m_reason = "Error while access database. Detail : " + dbe.getMessage();
197         } catch (AssertionException ae) {
198             // should never happen, maybe in the future we should remove the Assertion in getNumberOfBeans
199
log.fatal("Assertion error. Please correct it first.", ae);
200             m_shouldRun = false;
201             m_reason = "Assertion error. Detail : " + ae.getMessage();
202         }
203     }
204
205     private static Configuration freeMarkerConfiguration;
206     public static Configuration getFreeMarkerConfiguration() {
207         return freeMarkerConfiguration;
208     }
209
210     private static String JavaDoc MVNFORUM_HOME = "mvnForumHome";
211     public static String JavaDoc getMVNForumHome() {
212         return MVNFORUM_HOME;
213     }
214     public static String JavaDoc getTempDir() {
215         return tempDir;
216     }
217
218     public static int getSearchPostIndexType() {
219         return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
220         //return MVNForumGlobal.SEARCH_INDEX_TYPE_DATABASE;
221
}
222     public static String JavaDoc getSearchPostIndexDirName() {
223         if (getSearchPostIndexType() != MVNForumGlobal.SEARCH_INDEX_TYPE_DISK) {
224             throw new IllegalStateException JavaDoc("Cannot get search index dir name because type is not disk.");
225         }
226         return searchPostIndexDir;
227     }
228     public static Directory getSearchPostIndexDir(boolean create) throws IOException {
229         return FSDirectory.getDirectory(searchPostIndexDir, create);
230     }
231     public static Directory getSearchPostIndexDir() throws IOException {
232         return FSDirectory.getDirectory(searchPostIndexDir, false);
233     }
234     
235     public static int getSearchMemberIndexType() {
236         return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
237         //return MVNForumGlobal.SEARCH_INDEX_TYPE_DATABASE;
238
}
239     public static String JavaDoc getSearchMemberIndexDirName() {
240         if (getSearchMemberIndexType() != MVNForumGlobal.SEARCH_INDEX_TYPE_DISK) {
241             throw new IllegalStateException JavaDoc("Cannot get search index dir name because type is not disk.");
242         }
243         return searchMemberIndexDir;
244     }
245     public static Directory getSearchMemberIndexDir(boolean create) throws IOException {
246         return FSDirectory.getDirectory(searchMemberIndexDir, create);
247     }
248     public static Directory getSearchMemberIndexDir() throws IOException {
249         return FSDirectory.getDirectory(searchMemberIndexDir, false);
250     }
251     
252     public static int getSearchCompanyIndexType() {
253         return MVNForumGlobal.SEARCH_INDEX_TYPE_DISK;
254         //return MVNForumGlobal.SEARCH_INDEX_TYPE_DATABASE;
255
}
256     public static String JavaDoc getSearchCompanyIndexDirName() {
257         if (getSearchCompanyIndexType() != MVNForumGlobal.SEARCH_INDEX_TYPE_DISK) {
258             throw new IllegalStateException JavaDoc("Cannot get search index dir name because type is not disk.");
259         }
260         return searchCompanyIndexDir;
261     }
262     public static Directory getSearchCompanyIndexDir(boolean create) throws IOException {
263         return FSDirectory.getDirectory(searchCompanyIndexDir, create);
264     }
265     public static Directory getSearchCompanyIndexDir() throws IOException {
266         return FSDirectory.getDirectory(searchCompanyIndexDir, false);
267     }
268
269     public static String JavaDoc getAttachmentDir() {
270         return attachmentDir;
271     }
272     public static String JavaDoc getPmAttachmentDir() {
273         return pmAttachmentDir;
274     }
275
276     public static String JavaDoc getTemplateDir() {
277         return templateDir;
278     }
279
280     public static String JavaDoc getBackupDir() {
281         return backupDir;
282     }
283
284     public static String JavaDoc getLogDir() {
285         return logDir;
286     }
287
288     public static String JavaDoc getLogFile() {
289         return LOG_FILE;
290     }
291
292     public static String JavaDoc getAvatarDir() {
293         return avatarDir;
294     }
295
296     private static String JavaDoc REDIRECT_LOGIN_URL = "/login";
297     public static String JavaDoc getRedirectLoginURL() {
298         return REDIRECT_LOGIN_URL;
299     }
300
301     private static String JavaDoc WEBMASTER_EMAIL = "youremail@yourdomain.com";
302     public static String JavaDoc getWebMasterEmail() {
303         return WEBMASTER_EMAIL;
304     }
305
306     private static String JavaDoc LOGO_URL = "http://www.mvnForum.com";
307     public static String JavaDoc getLogoUrl() {
308         return LOGO_URL;
309     }
310
311     private static String JavaDoc[] SUPPORTED_LOCALE_NAMES = new String JavaDoc[0];
312     private static Locale JavaDoc[] SUPPORTED_LOCALES = new Locale JavaDoc[0];
313     public static String JavaDoc[] getSupportedLocaleNames() {
314         return SUPPORTED_LOCALE_NAMES;
315     }
316     public static Locale JavaDoc[] getSupportedLocales() {
317         return SUPPORTED_LOCALES;
318     }
319
320     private static String JavaDoc DEFAULT_LOCALE_NAME = "en";
321     private static Locale JavaDoc DEFAULT_LOCALE = null;
322     public static String JavaDoc getDefaultLocaleName() {
323         return DEFAULT_LOCALE_NAME;
324     }
325     public static Locale JavaDoc getDefaultLocale() {
326         return DEFAULT_LOCALE;
327     }
328
329     private static String JavaDoc LOCALE_PARAMETER_NAME = "lang";
330     public static String JavaDoc getLocaleParameterName() {
331         return LOCALE_PARAMETER_NAME;
332     }
333
334     /**
335      * Default username of a virtual Guest user. Will be overriden with the data
336      * from the database, if it exists (for the Guest user).
337      * Admin can give him a name he wants, like "Guest", "Anonymous", "Surfer",
338      * or even use a language different than English.
339      */

340     private static String JavaDoc DEFAULT_GUEST_NAME = "Guest";
341     public static String JavaDoc getDefaultGuestName() {
342         return DEFAULT_GUEST_NAME;
343     }
344
345     private static double DEFAULT_GUEST_TIMEZONE = 0;
346     public static double getDefaultGuestTimeZone() {
347         return DEFAULT_GUEST_TIMEZONE;
348     }
349
350     private static boolean ENABLE_PORTLET = false;
351     public static boolean getEnablePortlet() {
352         return ENABLE_PORTLET;
353     }
354
355     /**
356      * By default, mvnForum disable passwordless authentication
357      * If you want to authenticate user from realm or customized methods,
358      * then set the variable to true (AT YOUR OWN RISK, although I have not
359      * found any security issues until now)
360      */

361     private static boolean ENABLE_PASSWORDLESS_AUTH = false;
362     public static boolean getEnablePasswordlessAuth() {
363         return ENABLE_PASSWORDLESS_AUTH;
364     }
365
366     private static boolean REQUIRE_ACTIVATION = false;
367     public static boolean getRequireActivation() {
368         return REQUIRE_ACTIVATION;
369     }
370
371     private static boolean ENABLE_LOGIN_INFO_IN_COOKIE = true;
372     public static boolean getEnableLoginInfoInCookie() {
373         return ENABLE_LOGIN_INFO_IN_COOKIE;
374     }
375
376     private static boolean ENABLE_LOGIN_INFO_IN_SESSION = true;
377     public static boolean getEnableLoginInfoInSession() {
378         return ENABLE_LOGIN_INFO_IN_SESSION;
379     }
380
381     private static boolean ENABLE_LOGIN_INFO_IN_REALM = false;
382     public static boolean getEnableLoginInfoInRealm() {
383         return ENABLE_LOGIN_INFO_IN_REALM;
384     }
385
386     private static boolean ENABLE_LOGIN_INFO_IN_CUSTOMIZATION = false;
387     public static boolean getEnableLoginInfoInCustomization() {
388         return ENABLE_LOGIN_INFO_IN_CUSTOMIZATION;
389     }
390
391     private static boolean ENABLE_LOGIN = true;
392     public static boolean getEnableLogin() {
393         return ENABLE_LOGIN;
394     }
395
396     private static boolean ENABLE_CACHE_MEMBER = true;
397     public static boolean getEnableCacheMember() {
398         return ENABLE_CACHE_MEMBER;
399     }
400
401     private static boolean ENABLE_CACHE_POST = true;
402     public static boolean getEnableCachePost() {
403         return ENABLE_CACHE_POST;
404     }
405
406     private static boolean ENABLE_CACHE_THREAD = true;
407     public static boolean getEnableCacheThread() {
408         return ENABLE_CACHE_THREAD;
409     }
410
411     private static boolean ENABLE_CACHE_FORUM = true;
412     public static boolean getEnableCacheForum() {
413         return ENABLE_CACHE_FORUM;
414     }
415
416     private static boolean ENABLE_CACHE_CATEGORY = true;
417     public static boolean getEnableCacheCategory() {
418         return ENABLE_CACHE_CATEGORY;
419     }
420
421     private static boolean ENABLE_GUEST_VIEW_IMAGE_ATTACHMENT = false;
422     public static boolean getEnableGuestViewImageAttachment() {
423         return ENABLE_GUEST_VIEW_IMAGE_ATTACHMENT;
424     }
425
426     private static boolean ENABLE_NEW_MEMBER = true;
427     public static boolean getEnableNewMember() {
428         return ENABLE_NEW_MEMBER;
429     }
430
431     private static boolean ENABLE_NEW_POST = true;
432     public static boolean getEnableNewPost() {
433         return ENABLE_NEW_POST;
434     }
435
436     private static boolean ENABLE_AVATAR = true;
437     public static boolean getEnableAvatar() {
438         return ENABLE_AVATAR;
439     }
440
441     private static boolean ENABLE_EMOTICON = true;
442     public static boolean getEnableEmoticon() {
443         return ENABLE_EMOTICON;
444     }
445
446     private static boolean ENABLE_RSS = true;
447     public static boolean getEnableRSS() {
448         return ENABLE_RSS;
449     }
450
451     private static boolean ENABLE_SEARCH = true;
452     public static boolean getEnableSearch() {
453         return ENABLE_SEARCH;
454     }
455     private static boolean ENABLE_WATCH = true;
456     public static boolean getEnableWatch() {
457         return ENABLE_WATCH;
458     }
459
460     private static boolean ENABLE_ATTACHMENT = true;
461     public static boolean getEnableAttachment() {
462         return ENABLE_ATTACHMENT;
463     }
464
465     private static boolean ENABLE_MESSAGE_ATTACHMENT = true;
466     public static boolean getEnableMessageAttachment() {
467         return ENABLE_MESSAGE_ATTACHMENT;
468     }
469
470     private static boolean ENABLE_MOST_ACTIVE_THREADS = true;
471     public static boolean getEnableMostActiveThreads() {
472         return ENABLE_MOST_ACTIVE_THREADS;
473     }
474
475     private static boolean ENABLE_MOST_ACTIVE_MEMBERS = true;
476     public static boolean getEnableMostActiveMembers() {
477         return ENABLE_MOST_ACTIVE_MEMBERS;
478     }
479
480     private static boolean ENABLE_SITE_STATISTICS_OVERVIEW = true;
481     public static boolean getEnableSiteStatisticsOverview() {
482         return ENABLE_SITE_STATISTICS_OVERVIEW;
483     }
484
485     private static int MAX_ATTACHMENT_SIZE = 1024;
486     public static int getMaxAttachmentSize() {
487         return MAX_ATTACHMENT_SIZE;
488     }
489
490     private static int MAX_MESSAGE_ATTACHMENT_SIZE = 1024;
491     public static int getMaxMessageAttachmentSize() {
492         return MAX_MESSAGE_ATTACHMENT_SIZE;
493     }
494
495     // Default is false, but in KG it should be true
496
private static boolean ENABLE_AUTO_FORUM_OWNER = false;
497     public static boolean getEnableAutoForumOwner() {
498         return ENABLE_AUTO_FORUM_OWNER;
499     }
500
501     private static boolean ENABLE_CAPTCHA = false;
502     public static boolean getEnableCaptcha() {
503         return ENABLE_CAPTCHA;
504     }
505
506     private static boolean ENABLE_PORTAL_LIKE_INDEX_PAGE = true;
507     public static boolean getEnablePortalLikeIndexPage() {
508         return ENABLE_PORTAL_LIKE_INDEX_PAGE;
509     }
510
511     private static boolean ENABLE_ADMIN_CAN_CHANGE_PASSWORD = true;
512     public static boolean getEnableAdminCanChangePassword() {
513         return ENABLE_ADMIN_CAN_CHANGE_PASSWORD;
514     }
515
516     private static boolean ENABLE_SHOW_LAST_LOGIN = true;
517     public static boolean getEnableShowLastLogin() {
518         return ENABLE_SHOW_LAST_LOGIN;
519     }
520
521     private static boolean ENABLE_ONLINE_USERS = true;
522     public static boolean getEnableOnlineUsers() {
523         return ENABLE_ONLINE_USERS;
524     }
525
526     private static boolean ENABLE_DUPLICATE_ONLINE_USERS = true;
527     public static boolean getEnableDuplicateOnlineUsers() {
528         return ENABLE_DUPLICATE_ONLINE_USERS;
529     }
530
531     private static boolean ENABLE_INVISIBLE_USERS = true;
532     public static boolean getEnableInvisibleUsers() {
533         return ENABLE_INVISIBLE_USERS;
534     }
535
536     private static boolean ENABLE_LISTMEMBERS = true;
537     public static boolean getEnableListMembers() {
538         return ENABLE_LISTMEMBERS;
539     }
540
541     private static boolean ENABLE_PRIVATE_MESSAGE = true;
542     public static boolean getEnablePrivateMessage() {
543         return ENABLE_PRIVATE_MESSAGE;
544     }
545
546     private static boolean ENABLE_PUBLIC_MESSAGE = true;
547     public static boolean getEnablePublicMessage() {
548         return ENABLE_PUBLIC_MESSAGE;
549     }
550
551     // Default is false, but in Marco it should be true
552
private static boolean ENABLE_COMPANY = false;
553     public static boolean getEnableCompany() {
554         return ENABLE_COMPANY;
555     }
556
557     // Default is false, but in Marco it should be true or false
558
private static boolean ENABLE_LISTCOMPANIES = false;
559     public static boolean getEnableListCompanies() {
560         return ENABLE_LISTCOMPANIES;
561     }
562
563     private static int EXPIRE_DATE_TUTOR = 90;
564     public static int getExpireDateTutor() {
565         return EXPIRE_DATE_TUTOR;
566     }
567
568     private static int EXPIRE_SOON_DATE = 7;
569     public static int getUserTutorExpireSoonDate() {
570         return EXPIRE_SOON_DATE;
571     }
572
573     /**
574      * This is the maximum number of favorite threads that a user can add
575      */

576     private static int MAX_FAVORITE_THREAD = 128;
577     public static int getMaxFavoriteThread() {
578         return MAX_FAVORITE_THREAD;
579     }
580
581     private static int MAX_PRIVATE_MESSAGE = 128;
582     public static int getMaxPrivateMessage() {
583         return MAX_PRIVATE_MESSAGE;
584     }
585
586     private static int HOT_TOPIC_THRESHOLD = 10;
587     public static int getHotTopicThreshold() {
588         return HOT_TOPIC_THRESHOLD;
589     }
590
591     private static int MAX_POSTS_PER_HOUR = 20;
592     public static int getMaxPostsPerHour() {
593         return MAX_POSTS_PER_HOUR;
594     }
595
596     private static int MAX_MEMBERS_PER_HOUR = 2;
597     public static int getMaxMembersPerHour() {
598         return MAX_MEMBERS_PER_HOUR;
599     }
600
601     private static int MAX_LOGINS_PER_HOUR = 5;
602     public static int getMaxLoginsPerHour() {
603         return MAX_LOGINS_PER_HOUR;
604     }
605
606     private static int MAX_MESSAGES_PER_HOUR = 5;
607     public static int getMaxMessagesPerHour() {
608         return MAX_MESSAGES_PER_HOUR;
609     }
610
611     private static int MAX_ACTIVE_THREADS = 5;
612     public static int getMaxActiveThreads() {
613         return MAX_ACTIVE_THREADS;
614     }
615
616     private static int MAX_ACTIVE_MEMBERS = 5;
617     public static int getMaxActiveMembers() {
618         return MAX_ACTIVE_MEMBERS;
619     }
620
621     /** Do we allow storing backup files on the server? Currently not used. */
622     static boolean ENABLE_BACKUP_ON_SERVER = true;
623     public static final String JavaDoc BACKUP_FILE_PREFIX = "mvnForum-";
624     public static final String JavaDoc BACKUP_FILE_MainXmlFileNameInZip = "IMPORT.xml";
625     public static final String JavaDoc BACKUP_FILE_AvatarsDirNameInZip = "AVATARS/"; //must end with '/'
626
public static final String JavaDoc BACKUP_FILE_AttachsDirNameInZip = "ATTACHMENTS/"; //must end with '/'
627

628     /**
629      * Maximum size of the import file (in bytes) we will allow to be uploaded
630      * to server before processing.
631      */

632     private static int MAX_IMPORT_SIZE = 4096000;
633     /**
634      * Maximum size of the import file (in bytes) we will allow to be uploaded
635      * to server before processing.
636      */

637     public static int getMaxImportSize() {
638         return MAX_IMPORT_SIZE;
639     }
640
641     /**
642      * Type of import/export file: mvnForum XML.
643      * Import only database info, no attachments, message folders, avatars, ...
644      */

645     public static final int IMPORTEXPORT_TYPE_MVN_XML = 0;
646
647     /**
648      * Type of import file: mvnForum ZIP.
649      * Also import attachments, avatars, message folders
650      */

651     public static final int IMPORTEXPORT_TYPE_MVN_ZIP = 1;
652
653     /**
654      * Type of import file: Jive XML.
655      * Using <code>http://www.jivesoftware.com/jive.dtd</code>, xmlversion="1.0".
656      */

657     public static final int IMPORTEXPORT_TYPE_JIVE_XML = 2;
658
659     /**
660      * Output all messages, including errors, important messages and
661      * informational/status messages. This constant is used for specifing
662      * the level of output in various processess throughout the application.
663      */

664     public static final int MESSAGE_LEVEL_ALL_MESSAGES = 0;
665
666     /**
667      * Output only error messages and important messages (no
668      * informational/status messages). This constant is used for specifing
669      * the level of output in various processess throughout the application.
670      */

671     public static final int MESSAGE_LEVEL_IMPORTANT_MESSAGES = 1;
672
673     /**
674      * Output only error messages (no important messages, no
675      * informational/status messages). This constant is used for specifing
676      * the level of output in various processess throughout the application.
677      */

678     public static final int MESSAGE_LEVEL_ONLY_ERRORS = 2;
679
680     public final static long SESSION_DURATION = 30 * DateUtil.MINUTE;// SHOULD NOT less than 15 minutes
681

682     //public static final boolean DEFAULT_MESSAGE_ENABLE = true;
683
//public static final boolean DEFAULT_MEMBER_ENABLE = true;
684

685     /**
686      * Configurable number of days that a user can edit a post
687      */

688     private static int MAX_EDIT_DAYS = 7;
689     public static int getMaxEditDays() {
690         return MAX_EDIT_DAYS;
691     }
692
693     /**
694      * Configurable number of days that a user can attach file to a post
695      */

696     private static int MAX_ATTACH_DAYS = 1;
697     public static int getMaxAttachDays() {
698         return MAX_ATTACH_DAYS;
699     }
700
701     /**
702      * Configurable number of days that a user can delete a post
703      */

704     private static int MAX_DELETE_DAYS = 1;
705     public static int getMaxDeleteDays() {
706         return MAX_DELETE_DAYS;
707     }
708
709     /**
710      * Default number of rows (of Guest user) shown per page
711      */

712     private static int ROWS_PER_PAGE = 10;
713     public static int getRowsPerPage() {
714         return ROWS_PER_PAGE;
715     }
716
717     /**
718      * This is the number of rows returned when list threads for RSS
719      */

720     private static int ROWS_PER_RSS = 15;//RSS 0.91
721
public static int getRowsPerRSS() {
722         return ROWS_PER_RSS;
723     }
724
725     /**
726      * This is the default value of watch option
727      * @see com.mvnforum.db.WatchBean for the constant values
728      */

729     private static int DEFAULT_WATCH_OPTION = 0;
730     public static int getDefaultWatchOption() {
731         return DEFAULT_WATCH_OPTION;
732     }
733
734     private static int DEFAULT_MODERATION_OPTION = 0;
735     public static int getDefaultModerationOption() {
736         return DEFAULT_MODERATION_OPTION;
737     }
738
739     private static int MAX_CHARS_IN_SHORT_SUMMARY = 100;
740     public static int getMaxCharsInShortSummary() {
741         //getMaxCharsInPostInIndex
742
return MAX_CHARS_IN_SHORT_SUMMARY;
743     }
744
745     private static int MAX_CHARS_IN_LONG_SUMMARY = 1000;
746     public static int getMaxCharsInLongSummary() {
747         //getMaxCharsInPostInListthreads()
748
return MAX_CHARS_IN_LONG_SUMMARY;
749     }
750
751     private static int MAX_CHARS_IN_RSS = 500;
752     public static int getMaxCharsInRss() {
753         return MAX_CHARS_IN_RSS;
754     }
755
756     /**
757      * This is the number of reply rows returned when addpost (reply to a topic)
758      * /forum/addpost
759      */

760     public static final int ROWS_IN_LAST_REPLIES = 5;
761
762     /*
763     private static boolean parseBooleanValue(String propertyValue, boolean defaultValue) {
764         String result = "true";
765         try {
766             result = propertyValue.trim();
767             if ((result.equalsIgnoreCase("false")) || (result.equalsIgnoreCase("no"))) {
768                 return false;
769             } else if ((result.equalsIgnoreCase("true")) || (result.equalsIgnoreCase("yes"))) {
770                 return true;
771             } else {
772                 log.warn("Invalid boolean value in properties file. Should be \"true\", \"false\", \"yes\" or \"no\".");
773                 return defaultValue;
774             }
775         } catch (Exception e) {
776             log.warn(e.getMessage());
777             return defaultValue;
778         }
779     }
780
781     private static int parseIntValue(String propertyValue, int defaultValue) {
782         try {
783             return Integer.parseInt(propertyValue.trim());
784         } catch (Exception e) {
785             log.warn(e.getMessage());
786             return defaultValue;
787         }
788     }
789     */

790     private static int parseIntSizeValue(String JavaDoc propertyValue, int defaultValue) {
791         try {
792             String JavaDoc temp = propertyValue.trim();
793             if (temp.endsWith("B") || temp.endsWith("b")) {
794                 temp = temp.substring(0, temp.length() - 1);
795             }
796             switch (temp.charAt(temp.length()-1)) {
797                 case 'K': case 'k':
798                     //examples (ending 'B' was cut before): "1K", "1KB", "1k", "1kB", "1 K", "1 KB", "1 k", "1 kB"
799
return 1024 * Integer.parseInt(temp.substring(0, temp.length() - 1).trim());
800                 case 'M': case 'm':
801                     //examples (ending 'B' was cut before): "1M", "1MB", "1m", "1mB", "1 M", "1 MB", "1 m", "1 mB"
802
return 1024 * 1024 * Integer.parseInt(temp.substring(0, temp.length() - 1).trim());
803                 default:
804                     //examples (ending 'B' was cut before): "1", "1B", "1 B"
805
return Integer.parseInt(temp.trim());
806             }
807         } catch (Exception JavaDoc e) {
808             log.warn(e.getMessage());
809             return defaultValue;
810         }
811     }
812
813     static {
814         try {
815             load();
816
817             // now check if Guest user is in database or not
818
try {
819                 DAOFactory.getMemberDAO().getMember_forPublic(MVNForumConstant.MEMBER_ID_OF_GUEST);
820                 m_guestUserInDatabase = true;
821             } catch (ObjectNotFoundException ex) {
822                 // dont have Guest user in database, just ignore
823
} catch (Exception JavaDoc ex) {
824                 log.info("Error occured when get Guest user.", ex);
825             }
826
827             // Load FreeMarker configuration
828
freeMarkerConfiguration = new Configuration();
829             FileTemplateLoader templateLoader = new FileTemplateLoader(new File(MVNForumConfig.getTemplateDir()));
830             log.debug("Template directory = " + MVNForumConfig.getTemplateDir());
831             freeMarkerConfiguration.setTemplateLoader(templateLoader);
832         } catch (Exception JavaDoc e) {
833             String JavaDoc message = "com.mvnforum.MVNForumConfig: Can't read the configuration file: '" + OPTION_FILE_NAME + "'. Make sure the file is in your CLASSPATH";
834             log.error(message, e);
835             m_shouldRun = false;
836             m_reason = message;
837         }
838     }
839
840     public static void load() {
841         reload();
842     }
843
844     public static void reload() {
845
846         String JavaDoc strPathName = FileUtil.getServletClassesPath();
847         String JavaDoc configFilename = strPathName + OPTION_FILE_NAME;
848         try {
849             DOM4JConfiguration conf = new DOM4JConfiguration(new File(configFilename));
850
851             ENABLE_PORTLET = conf.getBoolean("mvnforumconfig.enable_portlet", ENABLE_PORTLET);
852
853             MVNFORUM_HOME = conf.getString("mvnforumconfig.mvnforum_home", "");
854             setMVNForumHome(MVNFORUM_HOME);
855
856             WEBMASTER_EMAIL = conf.getString("mvnforumconfig.webmaster_email", "");
857
858             LOGO_URL = conf.getString("mvnforumconfig.logo_url", LOGO_URL);
859
860             LOG_FILE = conf.getString("mvnforumconfig.mvnforum_log", "");
861
862             String JavaDoc supportedLocales = conf.getString("mvnforumconfig.supported_locales", "");
863             SUPPORTED_LOCALE_NAMES = StringUtil.getStringArray(supportedLocales, ";");
864
865             SUPPORTED_LOCALES = new Locale JavaDoc[SUPPORTED_LOCALE_NAMES.length];
866             for (int i = 0; i < SUPPORTED_LOCALE_NAMES.length; i++) {
867                 String JavaDoc localeName = SUPPORTED_LOCALE_NAMES[i];
868                 SUPPORTED_LOCALES[i] = MyUtil.getLocale(localeName);
869             }
870
871             try {
872                 DEFAULT_LOCALE_NAME = conf.getString("mvnforumconfig.default_locale_name", "");
873                 if (DEFAULT_LOCALE_NAME.length() == 0) {
874                     DEFAULT_LOCALE_NAME = "en";
875                 }
876             } catch (Exception JavaDoc ex) {
877                 log.warn(ex.getMessage());
878             }
879             DEFAULT_LOCALE = MyUtil.getLocale(DEFAULT_LOCALE_NAME);
880
881             try {
882                 DEFAULT_GUEST_NAME = conf.getString("mvnforumconfig.default_guest_name", DEFAULT_GUEST_NAME);
883             } catch (Exception JavaDoc ex) {
884                 log.warn(ex.getMessage());
885             }
886
887             DEFAULT_GUEST_TIMEZONE = conf.getDouble("mvnforumconfig.default_guest_timezone", DEFAULT_GUEST_TIMEZONE);
888             if ( Math.abs(DEFAULT_GUEST_TIMEZONE) > 12 ) {
889                 DEFAULT_GUEST_TIMEZONE = 0;
890             }
891
892             REDIRECT_LOGIN_URL = conf.getString("mvnforumconfig.redirect_login_url", REDIRECT_LOGIN_URL);
893             LOCALE_PARAMETER_NAME = conf.getString("mvnforumconfig.locale_parameter_name", LOCALE_PARAMETER_NAME);
894
895             ENABLE_PASSWORDLESS_AUTH = conf.getBoolean("mvnforumconfig.enable_passwordless_auth", false);
896             REQUIRE_ACTIVATION = conf.getBoolean("mvnforumconfig.require_activation", false);
897             ENABLE_LOGIN_INFO_IN_COOKIE = conf.getBoolean("mvnforumconfig.enable_login_info_in_cookie", true);
898             ENABLE_LOGIN_INFO_IN_SESSION = conf.getBoolean("mvnforumconfig.enable_login_info_in_session", true);
899             ENABLE_LOGIN_INFO_IN_REALM = conf.getBoolean("mvnforumconfig.enable_login_info_in_realm", false);
900             ENABLE_LOGIN_INFO_IN_CUSTOMIZATION = conf.getBoolean("mvnforumconfig.enable_login_info_in_customization", false);
901
902             ENABLE_CACHE_MEMBER = conf.getBoolean("mvnforumconfig.enable_cache_member", true);
903             ENABLE_CACHE_POST = conf.getBoolean("mvnforumconfig.enable_cache_post", true);
904             ENABLE_CACHE_THREAD = conf.getBoolean("mvnforumconfig.enable_cache_thread", true);
905             ENABLE_CACHE_FORUM = conf.getBoolean("mvnforumconfig.enable_cache_forum", true);
906             ENABLE_CACHE_CATEGORY = conf.getBoolean("mvnforumconfig.enable_cache_category", true);
907
908             ENABLE_LOGIN = conf.getBoolean("mvnforumconfig.enable_login", true);
909             ENABLE_NEW_MEMBER = conf.getBoolean("mvnforumconfig.enable_new_member", true);
910             ENABLE_NEW_POST = conf.getBoolean("mvnforumconfig.enable_new_post", true);
911             ENABLE_AVATAR = conf.getBoolean("mvnforumconfig.enable_avatar", true);
912             ENABLE_EMOTICON = conf.getBoolean("mvnforumconfig.enable_emoticon", true);
913             ENABLE_RSS = conf.getBoolean("mvnforumconfig.enable_rss", true);
914             ENABLE_SEARCH = conf.getBoolean("mvnforumconfig.enable_search", true);
915             ENABLE_WATCH = conf.getBoolean("mvnforumconfig.enable_watch", true);
916             ENABLE_ATTACHMENT = conf.getBoolean("mvnforumconfig.enable_attachment", true);
917             ENABLE_MESSAGE_ATTACHMENT = conf.getBoolean("mvnforumconfig.enable_message_attachment", true);
918             ENABLE_CAPTCHA = conf.getBoolean("mvnforumconfig.enable_captcha", false);
919             ENABLE_PORTAL_LIKE_INDEX_PAGE = conf.getBoolean("mvnforumconfig.enable_portal_like_index_page", true);
920             ENABLE_ADMIN_CAN_CHANGE_PASSWORD = conf.getBoolean("mvnforumconfig.enable_admin_can_change_password", true);
921             ENABLE_SHOW_LAST_LOGIN = conf.getBoolean("mvnforumconfig.enable_show_last_login", true);
922             ENABLE_ONLINE_USERS = conf.getBoolean("mvnforumconfig.enable_online_users", true);
923             ENABLE_LISTMEMBERS = conf.getBoolean("mvnforumconfig.enable_listmembers", true);
924             ENABLE_DUPLICATE_ONLINE_USERS = conf.getBoolean("mvnforumconfig.enable_duplicate_onlineusers", true);
925             ENABLE_INVISIBLE_USERS = conf.getBoolean("mvnforumconfig.enable_invisible_users", true);
926             ENABLE_PRIVATE_MESSAGE = conf.getBoolean("mvnforumconfig.enable_private_message", true);
927             ENABLE_PUBLIC_MESSAGE = conf.getBoolean("mvnforumconfig.enable_public_message", false);
928             ENABLE_GUEST_VIEW_IMAGE_ATTACHMENT = conf.getBoolean("mvnforumconfig.enable_guest_view_image_attachment", false);
929             ENABLE_MOST_ACTIVE_THREADS = conf.getBoolean("mvnforumconfig.enable_most_active_threads", true);
930             ENABLE_MOST_ACTIVE_MEMBERS = conf.getBoolean("mvnforumconfig.enable_most_active_members", true);
931             ENABLE_SITE_STATISTICS_OVERVIEW = conf.getBoolean("mvnforumconfig.enable_site_statistics_overview", false);
932
933             if (ENABLE_PORTLET) {
934                 //disable any authentication & user involving features
935
ENABLE_PASSWORDLESS_AUTH = false;
936                 REQUIRE_ACTIVATION = false;
937                 ENABLE_LOGIN_INFO_IN_COOKIE = false;
938                 ENABLE_LOGIN_INFO_IN_SESSION = false;
939                 ENABLE_CAPTCHA = false;
940                 ENABLE_SHOW_LAST_LOGIN = false;
941                 ENABLE_NEW_MEMBER = false;
942                 ENABLE_LOGIN = false;
943                 ENABLE_ADMIN_CAN_CHANGE_PASSWORD = false;
944                 ENABLE_LISTMEMBERS = false;
945
946                 // we check this feature later, should enable or not ?
947
ENABLE_SITE_STATISTICS_OVERVIEW = false;
948
949                 // enable these feature to check for satifying to create/update forum-account
950
ENABLE_LOGIN_INFO_IN_REALM = true;
951                 ENABLE_LOGIN_INFO_IN_CUSTOMIZATION = true;
952
953                 //String memberImpl = Portal.getMemberImplementation(PORTAL_TYPE);
954

955                 // We don't care these features because we prefer to control
956
// members accessing my forum than control all
957
// of members even the members never click on forum link
958

959                 //ENABLE_ONLINE_USERS = false;
960
//ENABLE_DUPLICATE_ONLINE_USERS = false;
961
//ENABLE_INVISIBLE_USERS = false;
962
}
963             /*
964             // Netmama
965             ENABLE_COMPANY = conf.getBoolean("mvnforumconfig.enable_company", false);
966             ENABLE_LISTCOMPANIES = conf.getBoolean("mvnforumconfig.enable_listcompanies", false);
967             EXPIRE_DATE_TUTOR = conf.getInt("mvnforumconfig.expire_date_tutor", 90);
968             EXPIRE_SOON_DATE = conf.getInt("mvnforumconfig.expire_soon_date", 7);
969             */

970             MAX_ATTACHMENT_SIZE = parseIntSizeValue(conf.getString("mvnforumconfig.max_attachment_size"), 1024);
971             if (MAX_ATTACHMENT_SIZE < -1) MAX_ATTACHMENT_SIZE = 0;// -1 is a valid value in common-upload, mean no maximum file size
972
MAX_MESSAGE_ATTACHMENT_SIZE = parseIntSizeValue(conf.getString("mvnforumconfig.max_message_attachment_size"), 1024);
973             if (MAX_MESSAGE_ATTACHMENT_SIZE < -1) MAX_MESSAGE_ATTACHMENT_SIZE = 0;// -1 is a valid value in common-upload, mean no maximum file size
974

975             MAX_FAVORITE_THREAD = conf.getInt("mvnforumconfig.max_favorite_thread", 128);
976             if (MAX_FAVORITE_THREAD < 0) MAX_FAVORITE_THREAD = 0;
977
978             MAX_PRIVATE_MESSAGE = conf.getInt("mvnforumconfig.max_private_message", 128);
979             if (MAX_PRIVATE_MESSAGE < 0) MAX_PRIVATE_MESSAGE = 0;
980
981             MAX_EDIT_DAYS = conf.getInt("mvnforumconfig.max_edit_days", 7);
982             if (MAX_EDIT_DAYS < 0) MAX_EDIT_DAYS = 0;
983
984             MAX_ATTACH_DAYS = conf.getInt("mvnforumconfig.max_attach_days", 1);
985             if (MAX_ATTACH_DAYS < 0) MAX_ATTACH_DAYS = 0;
986
987             MAX_DELETE_DAYS = conf.getInt("mvnforumconfig.max_delete_days", 1);
988             if (MAX_DELETE_DAYS < 0) MAX_DELETE_DAYS = 0;
989
990             ROWS_PER_PAGE = conf.getInt("mvnforumconfig.rows_per_page", 10);
991             if (ROWS_PER_PAGE < 5) ROWS_PER_PAGE = 5;
992
993             ROWS_PER_RSS = conf.getInt("mvnforumconfig.rows_per_rss", 15);
994             if (ROWS_PER_RSS < 5) ROWS_PER_RSS = 5;
995
996             HOT_TOPIC_THRESHOLD = conf.getInt("mvnforumconfig.hot_topic_threshold", 10);
997             if (HOT_TOPIC_THRESHOLD < 5) HOT_TOPIC_THRESHOLD = 5;
998
999             MAX_POSTS_PER_HOUR = conf.getInt("mvnforumconfig.max_posts_per_hour", MAX_POSTS_PER_HOUR);
1000            if (MAX_POSTS_PER_HOUR < 0) MAX_POSTS_PER_HOUR = 0;
1001
1002            MAX_MEMBERS_PER_HOUR = conf.getInt("mvnforumconfig.max_members_per_hour", MAX_MEMBERS_PER_HOUR);
1003            if (MAX_MEMBERS_PER_HOUR < 0) MAX_MEMBERS_PER_HOUR = 0;
1004
1005            MAX_LOGINS_PER_HOUR = conf.getInt("mvnforumconfig.max_logins_per_hour", MAX_LOGINS_PER_HOUR);
1006            if (MAX_LOGINS_PER_HOUR < 0) MAX_LOGINS_PER_HOUR = 0;
1007
1008            MAX_MESSAGES_PER_HOUR = conf.getInt("mvnforumconfig.max_messages_per_hour", MAX_MESSAGES_PER_HOUR);
1009            if (MAX_MESSAGES_PER_HOUR < 0) MAX_MESSAGES_PER_HOUR = 0;
1010
1011            MAX_CHARS_IN_SHORT_SUMMARY = conf.getInt("mvnforumconfig.max_chars_in_short_summary", MAX_CHARS_IN_SHORT_SUMMARY);
1012            if (MAX_CHARS_IN_SHORT_SUMMARY <= 0) MAX_CHARS_IN_SHORT_SUMMARY = Integer.MAX_VALUE;
1013
1014            MAX_CHARS_IN_LONG_SUMMARY = conf.getInt("mvnforumconfig.max_chars_in_long_summary", MAX_CHARS_IN_LONG_SUMMARY);
1015            if (MAX_CHARS_IN_LONG_SUMMARY <= 0) MAX_CHARS_IN_LONG_SUMMARY = Integer.MAX_VALUE;
1016
1017            MAX_CHARS_IN_RSS = conf.getInt("mvnforumconfig.max_chars_in_rss", MAX_CHARS_IN_RSS);
1018            if (MAX_CHARS_IN_RSS <= 0) MAX_CHARS_IN_RSS = Integer.MAX_VALUE;
1019
1020            ENABLE_BACKUP_ON_SERVER = conf.getBoolean("mvnforumconfig.enable_backup_on_server", true);
1021            MAX_IMPORT_SIZE = parseIntSizeValue(conf.getString("mvnforumconfig.max_import_size", "4096000"), 4096000 );
1022
1023            DEFAULT_WATCH_OPTION = conf.getInt("mvnforumconfig.default_watch_option", 0);
1024            if (DEFAULT_WATCH_OPTION < 0 || DEFAULT_WATCH_OPTION > 4) DEFAULT_WATCH_OPTION = 0;
1025
1026            DEFAULT_MODERATION_OPTION = conf.getInt("mvnforumconfig.default_moderation_option", 0);
1027            if (DEFAULT_MODERATION_OPTION < 0 || DEFAULT_MODERATION_OPTION > 4) DEFAULT_MODERATION_OPTION = 0;
1028
1029            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_NEW_MEMBER, MAX_MEMBERS_PER_HOUR);
1030            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_NEW_POST, MAX_POSTS_PER_HOUR);
1031            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_LOGIN, MAX_LOGINS_PER_HOUR);
1032            FloodControl.setOption(MVNForumGlobal.FLOOD_ID_NEW_MESSAGE, MAX_MESSAGES_PER_HOUR);
1033        } catch (Exception JavaDoc e) {
1034            // Please note that for security reason, the full path file name is logged
1035
// to the log file only. And the reason that show on the web should only
1036
// show the filename only
1037
String JavaDoc message = "com.mvnforum.MVNForumConfig: Can't read the configuration file: '" + configFilename + "'. Make sure the file is in your CLASSPATH";
1038            log.error(message, e);
1039            m_shouldRun = false;
1040            m_reason = "com.mvnforum.MVNForumConfig: Can't read the configuration file: '" + OPTION_FILE_NAME + "'. Make sure the file is in your CLASSPATH";
1041        }
1042    }
1043
1044    public static boolean supportLocale(String JavaDoc localeName) {
1045        if ((localeName == null) || (localeName.length() == 0)) {
1046            return false;
1047        }
1048
1049        String JavaDoc[] supportedLocaleNames = MVNForumConfig.getSupportedLocaleNames();
1050        if (supportedLocaleNames == null) {
1051            log.fatal("Assertion in MVNForumConfig: supportedLocales is null. Please check your configuration.");
1052            return false;
1053        }
1054
1055        for (int i = 0; i < supportedLocaleNames.length; i++) {
1056            if (localeName.equals(supportedLocaleNames[i])) {
1057                return true;
1058            }
1059        }
1060        return false;
1061    }
1062}
1063
Popular Tags