Source Code Cross Referenced for ConfigurationWebHandler.java in  » Forum » mvnforum-1.1 » com » mvnforum » admin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Forum » mvnforum 1.1 » com.mvnforum.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/admin/ConfigurationWebHandler.java,v 1.107 2008/01/29 08:09:17 minhnn Exp $
0003:         * $Author: minhnn $
0004:         * $Revision: 1.107 $
0005:         * $Date: 2008/01/29 08:09:17 $
0006:         *
0007:         * ====================================================================
0008:         *
0009:         * Copyright (C) 2002-2007 by MyVietnam.net
0010:         *
0011:         * All copyright notices regarding mvnForum MUST remain
0012:         * intact in the scripts and in the outputted HTML.
0013:         * The "powered by" text/logo with a link back to
0014:         * http://www.mvnForum.com and http://www.MyVietnam.net in
0015:         * the footer of the pages MUST remain visible when the pages
0016:         * are viewed on the internet or intranet.
0017:         *
0018:         * This program is free software; you can redistribute it and/or modify
0019:         * it under the terms of the GNU General Public License as published by
0020:         * the Free Software Foundation; either version 2 of the License, or
0021:         * any later version.
0022:         *
0023:         * This program is distributed in the hope that it will be useful,
0024:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0025:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026:         * GNU General Public License for more details.
0027:         *
0028:         * You should have received a copy of the GNU General Public License
0029:         * along with this program; if not, write to the Free Software
0030:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0031:         *
0032:         * Support can be obtained from support forums at:
0033:         * http://www.mvnForum.com/mvnforum/index
0034:         *
0035:         * Correspondence and Marketing Questions can be sent to:
0036:         * info at MyVietnam net
0037:         *
0038:         * @author: Minh Nguyen
0039:         * @author: Mai  Nguyen
0040:         */
0041:        package com.mvnforum.admin;
0042:
0043:        import java.io.*;
0044:        import java.util.*;
0045:
0046:        import net.myvietnam.mvncore.MVNCoreConfig;
0047:        import net.myvietnam.mvncore.configuration.DOM4JConfiguration;
0048:        import net.myvietnam.mvncore.exception.BadInputException;
0049:        import net.myvietnam.mvncore.exception.DatabaseException;
0050:        import net.myvietnam.mvncore.security.SecurityUtil;
0051:        import net.myvietnam.mvncore.service.EnvironmentService;
0052:        import net.myvietnam.mvncore.service.MvnCoreServiceFactory;
0053:        import net.myvietnam.mvncore.util.*;
0054:        import net.myvietnam.mvncore.web.GenericRequest;
0055:
0056:        import org.apache.commons.logging.Log;
0057:        import org.apache.commons.logging.LogFactory;
0058:        import org.dom4j.*;
0059:        import org.dom4j.io.SAXReader;
0060:        import org.dom4j.io.XMLWriter;
0061:
0062:        import com.mvnforum.*;
0063:        import com.mvnforum.auth.*;
0064:        import com.mvnforum.db.*;
0065:
0066:        import freemarker.template.*;
0067:
0068:        public class ConfigurationWebHandler {
0069:
0070:            private static Log log = LogFactory
0071:                    .getLog(ConfigurationWebHandler.class);
0072:
0073:            private OnlineUserManager onlineUserManager = OnlineUserManager
0074:                    .getInstance();
0075:
0076:            public ConfigurationWebHandler() {
0077:            }
0078:
0079:            public void prepareConfigMVNForum(GenericRequest request)
0080:                    throws IOException, DatabaseException,
0081:                    AuthenticationException {
0082:
0083:                OnlineUser onlineUser = onlineUserManager
0084:                        .getOnlineUser(request);
0085:                MVNForumPermission permission = onlineUser.getPermission();
0086:                permission.ensureCanAdminSystem();
0087:
0088:                String strPathName = FileUtil.getServletClassesPath();
0089:                DOM4JConfiguration mvnforumConfig;
0090:                try {
0091:                    mvnforumConfig = new DOM4JConfiguration(new File(
0092:                            strPathName + "mvnforum.xml"));
0093:                } catch (Exception ex) {
0094:                    log.error("Cannot load the DOM4JConfiguration.", ex);
0095:                    throw new IOException("Cannot load the DOM4JConfiguration.");
0096:                }
0097:
0098:                request.setAttribute("mvnforumConfig", mvnforumConfig);
0099:            }
0100:
0101:            public void prepareConfigMVNCore(GenericRequest request)
0102:                    throws IOException, DatabaseException,
0103:                    AuthenticationException {
0104:
0105:                OnlineUser onlineUser = onlineUserManager
0106:                        .getOnlineUser(request);
0107:                MVNForumPermission permission = onlineUser.getPermission();
0108:                permission.ensureCanAdminSystem();
0109:
0110:                String strPathName = FileUtil.getServletClassesPath();
0111:                DOM4JConfiguration mvncoreConfig;
0112:                try {
0113:                    mvncoreConfig = new DOM4JConfiguration(new File(strPathName
0114:                            + "mvncore.xml"));
0115:                } catch (Exception ex) {
0116:                    log.error("Cannot load the DOM4JConfiguration.", ex);
0117:                    throw new IOException("Cannot load the DOM4JConfiguration.");
0118:                }
0119:
0120:                request.setAttribute("mvncoreConfig", mvncoreConfig);
0121:            }
0122:
0123:            public void updateConfigStepOne(GenericRequest request)
0124:                    throws BadInputException, DocumentException, IOException,
0125:                    DatabaseException, AuthenticationException {
0126:
0127:                SecurityUtil.checkHttpPostMethod(request);
0128:
0129:                OnlineUser onlineUser = onlineUserManager
0130:                        .getOnlineUser(request);
0131:                MVNForumPermission permission = onlineUser.getPermission();
0132:                permission.ensureCanAdminSystem();
0133:
0134:                // Children of mvnforumConfig
0135:                String mvnforum_home = GenericParamUtil.getParameterSafe(
0136:                        request, "mvnforum_home", true);
0137:                String mvnforum_log = GenericParamUtil.getParameterSafe(
0138:                        request, "mvnforum_log", true);
0139:                String webmaster_email = GenericParamUtil.getParameterEmail(
0140:                        request, "webmaster_email");
0141:                String watch_email = GenericParamUtil.getParameterEmail(
0142:                        request, "watch_email");
0143:                String logo_url = GenericParamUtil.getParameterSafe(request,
0144:                        "logo_url", true);
0145:                String redirect_login_url = GenericParamUtil.getParameterSafe(
0146:                        request, "redirect_login_url", true);
0147:                String redirect_logout_url = GenericParamUtil.getParameterSafe(
0148:                        request, "redirect_logout_url", true);
0149:                String supported_locales = GenericParamUtil.getParameterSafe(
0150:                        request, "supported_locales", false);
0151:                String default_locale_name = GenericParamUtil.getParameterSafe(
0152:                        request, "default_locale_name", true);
0153:                String locale_parameter_name = GenericParamUtil
0154:                        .getParameterSafe(request, "locale_parameter_name",
0155:                                true);
0156:                String default_guest_name = GenericParamUtil.getParameterSafe(
0157:                        request, "default_guest_name", true);
0158:                int default_guest_timezone = GenericParamUtil.getParameterInt(
0159:                        request, "default_guest_timezone");
0160:                int default_status_of_registered_member = GenericParamUtil
0161:                        .getParameterInt(request,
0162:                                "default_status_of_registered_member");
0163:                boolean enable_register_rule = GenericParamUtil
0164:                        .getParameterBoolean(request, "enable_register_rule");
0165:
0166:                boolean enable_cache_member = GenericParamUtil
0167:                        .getParameterBoolean(request, "enable_cache_member");
0168:                boolean enable_cache_post = GenericParamUtil
0169:                        .getParameterBoolean(request, "enable_cache_post");
0170:                boolean enable_cache_thread = GenericParamUtil
0171:                        .getParameterBoolean(request, "enable_cache_thread");
0172:                boolean enable_cache_forum = GenericParamUtil
0173:                        .getParameterBoolean(request, "enable_cache_forum");
0174:                boolean enable_cache_category = GenericParamUtil
0175:                        .getParameterBoolean(request, "enable_cache_category");
0176:
0177:                boolean enable_passwordless_auth = GenericParamUtil
0178:                        .getParameterBoolean(request,
0179:                                "enable_passwordless_auth");
0180:                boolean enable_login_info_in_cookie = GenericParamUtil
0181:                        .getParameterBoolean(request,
0182:                                "enable_login_info_in_cookie");
0183:                boolean enable_login_info_in_session = GenericParamUtil
0184:                        .getParameterBoolean(request,
0185:                                "enable_login_info_in_session");
0186:                boolean enable_login_info_in_realm = GenericParamUtil
0187:                        .getParameterBoolean(request,
0188:                                "enable_login_info_in_realm");
0189:                boolean enable_login_info_in_customization = GenericParamUtil
0190:                        .getParameterBoolean(request,
0191:                                "enable_login_info_in_customization");
0192:                boolean enable_check_invalid_session = GenericParamUtil
0193:                        .getParameterBoolean(request,
0194:                                "enable_check_invalid_session");
0195:                boolean require_activation = GenericParamUtil
0196:                        .getParameterBoolean(request, "require_activation");
0197:                boolean enable_login = GenericParamUtil.getParameterBoolean(
0198:                        request, "enable_login");
0199:                boolean enable_new_member = GenericParamUtil
0200:                        .getParameterBoolean(request, "enable_new_member");
0201:                boolean enable_new_post = GenericParamUtil.getParameterBoolean(
0202:                        request, "enable_new_post");
0203:                boolean enable_rss = GenericParamUtil.getParameterBoolean(
0204:                        request, "enable_rss");
0205:                boolean enable_watch = GenericParamUtil.getParameterBoolean(
0206:                        request, "enable_watch");
0207:                boolean enable_attachment = GenericParamUtil
0208:                        .getParameterBoolean(request, "enable_attachment");
0209:                boolean enable_avatar = GenericParamUtil.getParameterBoolean(
0210:                        request, "enable_avatar");
0211:                boolean enable_emoticon = GenericParamUtil.getParameterBoolean(
0212:                        request, "enable_emoticon");
0213:                boolean enable_captcha = GenericParamUtil.getParameterBoolean(
0214:                        request, "enable_captcha");
0215:                boolean enable_portal_like_index_page = GenericParamUtil
0216:                        .getParameterBoolean(request,
0217:                                "enable_portal_like_index_page");
0218:
0219:                boolean enable_search = GenericParamUtil.getParameterBoolean(
0220:                        request, "enable_search");
0221:                boolean enable_online_users = GenericParamUtil
0222:                        .getParameterBoolean(request, "enable_online_users");
0223:                boolean enable_duplicate_onlineusers = GenericParamUtil
0224:                        .getParameterBoolean(request,
0225:                                "enable_duplicate_onlineusers");
0226:                boolean enable_invisible_users = GenericParamUtil
0227:                        .getParameterBoolean(request, "enable_invisible_users");
0228:                boolean enable_listmembers = GenericParamUtil
0229:                        .getParameterBoolean(request, "enable_listmembers");
0230:                boolean enable_show_last_login_of_current_member = GenericParamUtil
0231:                        .getParameterBoolean(request,
0232:                                "enable_show_last_login_of_current_member");
0233:                boolean enable_show_last_login = GenericParamUtil
0234:                        .getParameterBoolean(request, "enable_show_last_login");
0235:                boolean enable_auto_watching = GenericParamUtil
0236:                        .getParameterBoolean(request, "enable_auto_watching");
0237:
0238:                boolean enable_show_birthday = GenericParamUtil
0239:                        .getParameterBoolean(request, "enable_show_birthday");
0240:                boolean enable_show_gender = GenericParamUtil
0241:                        .getParameterBoolean(request, "enable_show_gender");
0242:                boolean enable_show_address = GenericParamUtil
0243:                        .getParameterBoolean(request, "enable_show_address");
0244:                boolean enable_show_city = GenericParamUtil
0245:                        .getParameterBoolean(request, "enable_show_city");
0246:                boolean enable_show_state = GenericParamUtil
0247:                        .getParameterBoolean(request, "enable_show_state");
0248:                boolean enable_show_country = GenericParamUtil
0249:                        .getParameterBoolean(request, "enable_show_country");
0250:                boolean enable_show_phone = GenericParamUtil
0251:                        .getParameterBoolean(request, "enable_show_phone");
0252:                boolean enable_show_mobile = GenericParamUtil
0253:                        .getParameterBoolean(request, "enable_show_mobile");
0254:                boolean enable_show_career = GenericParamUtil
0255:                        .getParameterBoolean(request, "enable_show_career");
0256:                boolean enable_show_homepage = GenericParamUtil
0257:                        .getParameterBoolean(request, "enable_show_homepage");
0258:                boolean enable_show_cool_link_1 = GenericParamUtil
0259:                        .getParameterBoolean(request, "enable_show_cool_link_1");
0260:                boolean enable_show_cool_link_2 = GenericParamUtil
0261:                        .getParameterBoolean(request, "enable_show_cool_link_2");
0262:                boolean enable_show_yahoo = GenericParamUtil
0263:                        .getParameterBoolean(request, "enable_show_yahoo");
0264:                boolean enable_show_aol = GenericParamUtil.getParameterBoolean(
0265:                        request, "enable_show_aol");
0266:                boolean enable_show_icq = GenericParamUtil.getParameterBoolean(
0267:                        request, "enable_show_icq");
0268:                boolean enable_show_msn = GenericParamUtil.getParameterBoolean(
0269:                        request, "enable_show_msn");
0270:                boolean enable_show_join_date = GenericParamUtil
0271:                        .getParameterBoolean(request, "enable_show_join_date");
0272:                boolean enable_show_post_count = GenericParamUtil
0273:                        .getParameterBoolean(request, "enable_show_post_count");
0274:                boolean enable_show_online_status = GenericParamUtil
0275:                        .getParameterBoolean(request,
0276:                                "enable_show_online_status");
0277:                boolean enable_show_lastname = GenericParamUtil
0278:                        .getParameterBoolean(request, "enable_show_lastname");
0279:                boolean enable_show_firstname = GenericParamUtil
0280:                        .getParameterBoolean(request, "enable_show_firstname");
0281:                boolean enable_show_view_count = GenericParamUtil
0282:                        .getParameterBoolean(request, "enable_show_view_count");
0283:                boolean enable_show_email = GenericParamUtil
0284:                        .getParameterBoolean(request, "enable_show_email");
0285:
0286:                boolean enable_use_popup_menu_in_viewthread = GenericParamUtil
0287:                        .getParameterBoolean(request,
0288:                                "enable_use_popup_menu_in_viewthread");
0289:                boolean enable_split_thread = GenericParamUtil
0290:                        .getParameterBoolean(request, "enable_split_thread");
0291:                boolean enable_listunansweredthreads = GenericParamUtil
0292:                        .getParameterBoolean(request,
0293:                                "enable_listunansweredthreads");
0294:                boolean enable_list_users_browsing_thread = GenericParamUtil
0295:                        .getParameterBoolean(request,
0296:                                "enable_list_users_browsing_thread");
0297:                boolean enable_email_to_admin_content_with_censored_words = GenericParamUtil
0298:                        .getParameterBoolean(request,
0299:                                "enable_email_to_admin_content_with_censored_words");
0300:                boolean enable_guest_view_listusers = GenericParamUtil
0301:                        .getParameterBoolean(request,
0302:                                "enable_guest_view_listusers");
0303:                boolean only_normal_thread_type_in_active_threads = GenericParamUtil
0304:                        .getParameterBoolean(request,
0305:                                "only_normal_thread_type_in_active_threads");
0306:                boolean send_watchmail_as_html = GenericParamUtil
0307:                        .getParameterBoolean(request, "send_watchmail_as_html");
0308:                boolean enable_easy_watching = GenericParamUtil
0309:                        .getParameterBoolean(request, "enable_easy_watching");
0310:                boolean enable_send_watch_mail_of_my_own_post = GenericParamUtil
0311:                        .getParameterBoolean(request,
0312:                                "enable_send_watch_mail_of_my_own_post");
0313:
0314:                boolean enable_private_message = GenericParamUtil
0315:                        .getParameterBoolean(request, "enable_private_message");
0316:                boolean enable_public_message = GenericParamUtil
0317:                        .getParameterBoolean(request, "enable_public_message");
0318:                boolean enable_message_attachment = GenericParamUtil
0319:                        .getParameterBoolean(request,
0320:                                "enable_message_attachment");
0321:                boolean enable_most_active_threads = GenericParamUtil
0322:                        .getParameterBoolean(request,
0323:                                "enable_most_active_threads");
0324:                boolean enable_most_active_members = GenericParamUtil
0325:                        .getParameterBoolean(request,
0326:                                "enable_most_active_members");
0327:                boolean enable_site_statistics_overview = GenericParamUtil
0328:                        .getParameterBoolean(request,
0329:                                "enable_site_statistics_overview");
0330:                boolean enable_admin_can_change_password = GenericParamUtil
0331:                        .getParameterBoolean(request,
0332:                                "enable_admin_can_change_password");
0333:                boolean enable_guest_view_image_attachment = GenericParamUtil
0334:                        .getParameterBoolean(request,
0335:                                "enable_guest_view_image_attachment");
0336:                boolean enable_expanse_category_tree_by_default = GenericParamUtil
0337:                        .getParameterBoolean(request,
0338:                                "enable_expanse_category_tree_by_default");
0339:
0340:                boolean enable_encrypt_password_on_browser = GenericParamUtil
0341:                        .getParameterBoolean(request,
0342:                                "enable_encrypt_password_on_browser");
0343:                boolean enable_external_user_database = GenericParamUtil
0344:                        .getParameterBoolean(request,
0345:                                "enable_external_user_database");
0346:                int days_to_show_recent_members = GenericParamUtil
0347:                        .getParameterInt(request, "days_to_show_recent_members");
0348:                boolean enable_list_new_members_in_recent_days = GenericParamUtil
0349:                        .getParameterBoolean(request,
0350:                                "enable_list_new_members_in_recent_days");
0351:                boolean enable_list_users_browsing_forum = GenericParamUtil
0352:                        .getParameterBoolean(request,
0353:                                "enable_list_users_browsing_forum");
0354:                boolean enable_email_threatening_content = GenericParamUtil
0355:                        .getParameterBoolean(request,
0356:                                "enable_email_threatening_content");
0357:                boolean have_internet = GenericParamUtil.getParameterBoolean(
0358:                        request, "have_internet");
0359:                String event_log_locale = GenericParamUtil.getParameterSafe(
0360:                        request, "event_log_locale", true);
0361:                int default_category_id = GenericParamUtil.getParameterInt(
0362:                        request, "default_category_id");
0363:                int default_watch_type = GenericParamUtil.getParameterInt(
0364:                        request, "default_watch_type");
0365:
0366:                int default_watch_option = GenericParamUtil.getParameterInt(
0367:                        request, "default_watch_option");
0368:                int default_moderation_option = GenericParamUtil
0369:                        .getParameterInt(request, "default_moderation_option");
0370:
0371:                boolean enable_image_thumbnail = GenericParamUtil
0372:                        .getParameterBoolean(request, "enable_image_thumbnail");
0373:                int image_thumbnail_width = 0;
0374:                int image_thumbnail_height = 0;
0375:                if (enable_image_thumbnail) {
0376:                    image_thumbnail_width = GenericParamUtil.getParameterInt(
0377:                            request, "image_thumbnail_width");
0378:                    image_thumbnail_height = GenericParamUtil.getParameterInt(
0379:                            request, "image_thumbnail_height");
0380:                }
0381:
0382:                // children of mvnforumfactoryconfig
0383:                String member_implementation = GenericParamUtil
0384:                        .getParameterSafe(request, "member_implementation",
0385:                                true);
0386:                String onlineuser_implementation = GenericParamUtil
0387:                        .getParameterSafe(request, "onlineuser_implementation",
0388:                                true);
0389:                String authenticator_implementation = GenericParamUtil
0390:                        .getParameterSafe(request,
0391:                                "authenticator_implementation", false);
0392:                String requestprocessor_implementation = GenericParamUtil
0393:                        .getParameterSafe(request,
0394:                                "requestprocessor_implementation", true);
0395:                String lucene_analyzer_implementation = GenericParamUtil
0396:                        .getParameterSafe(request,
0397:                                "lucene_analyzer_implementation", true);
0398:                String mvnforum_service_implementation = GenericParamUtil
0399:                        .getParameterSafe(request,
0400:                                "mvnforum_service_implementation", true);
0401:                String mvn_auth_service_implementation = GenericParamUtil
0402:                        .getParameterSafe(request,
0403:                                "mvn_auth_service_implementation", true);
0404:
0405:                WatchBean.validateWatchOption(default_watch_option);
0406:                ForumBean
0407:                        .validateForumModerationMode(default_moderation_option);
0408:                MemberBean
0409:                        .validateMemberStatus(default_status_of_registered_member);
0410:                WatchBean.validateWatchType(default_watch_type);
0411:
0412:                // Now checking the validity of value
0413:                Locale locale = onlineUser.getLocale();
0414:
0415:                try {
0416:                    // Create a directory if it does not exist
0417:                    FileUtil.createDirs(mvnforum_home, true);
0418:
0419:                    String tempFilename = mvnforum_home + File.separatorChar
0420:                            + "mvnforum_tempfile.tmp";
0421:                    File tempFile = new File(tempFilename);
0422:                    if (log.isDebugEnabled()) {
0423:                        log.debug("Temp file = " + tempFilename);
0424:                        log.debug("Absolute filename of temp file = "
0425:                                + tempFile.getAbsolutePath());
0426:                    }
0427:
0428:                    FileOutputStream fos = new FileOutputStream(tempFilename);
0429:                    fos.write(tempFilename.getBytes());
0430:                    fos.close();
0431:
0432:                    tempFile.delete();
0433:                } catch (IOException ex) {
0434:                    String errorMessage = "Check your mvnforum_home. Detail : "
0435:                            + ex.getMessage();
0436:                    throw new BadInputException(errorMessage);
0437:                }
0438:
0439:                try {
0440:                    int lastBackSlashIndex = mvnforum_log.lastIndexOf('\\');
0441:                    int lastForwardSlashIndex = mvnforum_log.lastIndexOf('/');
0442:                    int index = Math.max(lastBackSlashIndex,
0443:                            lastForwardSlashIndex);
0444:                    if (index < 0) {
0445:                        throw new BadInputException(
0446:                                "Cannot find any '\\' or '/' in mvnforum_log : "
0447:                                        + mvnforum_log);
0448:                    }
0449:                    String parentFolder = mvnforum_log.substring(0, index);
0450:                    log.debug("parentFolder = " + parentFolder);
0451:
0452:                    // always create a dir, if the dir already exitsted, nothing happens
0453:                    FileUtil.createDirs(parentFolder, true);
0454:
0455:                    String tempFilename = parentFolder + File.separatorChar
0456:                            + "mvnforum_tempfile.tmp";
0457:                    File tempFile = new File(tempFilename);
0458:                    if (log.isDebugEnabled()) {
0459:                        log.debug("Temp file in log folder = " + tempFilename);
0460:                        log
0461:                                .debug("Absolute filename of temp file in log folder = "
0462:                                        + tempFile.getAbsolutePath());
0463:                    }
0464:
0465:                    FileOutputStream fos = new FileOutputStream(tempFilename);
0466:                    fos.write(tempFilename.getBytes());
0467:                    fos.close();
0468:
0469:                    tempFile.delete();
0470:                } catch (IOException ex) {
0471:                    String errorMessage = "Check your mvnforum_log. Detail : "
0472:                            + ex.getMessage();
0473:                    throw new BadInputException(errorMessage);
0474:                }
0475:
0476:                MyUtil.checkClassName(locale, member_implementation, true);
0477:                MyUtil.checkClassName(locale, onlineuser_implementation, true);
0478:                MyUtil.checkClassName(locale, authenticator_implementation,
0479:                        false);
0480:                MyUtil.checkClassName(locale, requestprocessor_implementation,
0481:                        true);
0482:                MyUtil.checkClassName(locale, lucene_analyzer_implementation,
0483:                        true);
0484:                MyUtil.checkClassName(locale, mvnforum_service_implementation,
0485:                        true);
0486:                MyUtil.checkClassName(locale, mvn_auth_service_implementation,
0487:                        true);
0488:
0489:                // End checking, now save the value
0490:                String strPathName = FileUtil.getServletClassesPath();
0491:                SAXReader reader = new SAXReader();
0492:                Document document = reader.read(new File(strPathName
0493:                        + "mvnforum.xml"));
0494:
0495:                Element root = document.getRootElement();
0496:
0497:                // Iterate through child elements of root
0498:                for (Iterator i = root.elementIterator(); i.hasNext();) {
0499:                    Element element = (Element) i.next();
0500:                    for (int j = 0, size = element.nodeCount(); j < size; j++) {
0501:                        Node node = element.node(j);
0502:                        if (node.getNodeTypeName().equals("Element")) {
0503:                            if (node.getName().equals("mvnforum_home")) {
0504:                                node.setText(mvnforum_home);
0505:                            } else if (node.getName().equals("mvnforum_log")) {
0506:                                node.setText(mvnforum_log);
0507:                            } else if (node.getName().equals("webmaster_email")) {
0508:                                node.setText(webmaster_email);
0509:                            } else if (node.getName().equals("watch_email")) {
0510:                                node.setText(watch_email);
0511:                            } else if (node.getName().equals("logo_url")) {
0512:                                node.setText(logo_url);
0513:                            } else if (node.getName().equals(
0514:                                    "redirect_login_url")) {
0515:                                node.setText(redirect_login_url);
0516:                            } else if (node.getName().equals(
0517:                                    "redirect_logout_url")) {
0518:                                node.setText(redirect_logout_url);
0519:                            } else if (node.getName().equals(
0520:                                    "supported_locales")) {
0521:                                node.setText(supported_locales);
0522:                            } else if (node.getName().equals(
0523:                                    "default_locale_name")) {
0524:                                node.setText(default_locale_name);
0525:                            } else if (node.getName().equals(
0526:                                    "locale_parameter_name")) {
0527:                                node.setText(locale_parameter_name);
0528:                            } else if (node.getName().equals(
0529:                                    "default_guest_name")) {
0530:                                node.setText(default_guest_name);
0531:                            } else if (node.getName().equals(
0532:                                    "default_guest_timezone")) {
0533:                                node.setText(String
0534:                                        .valueOf(default_guest_timezone));
0535:
0536:                            } else if (node.getName().equals(
0537:                                    "enable_cache_member")) {
0538:                                node.setText(String
0539:                                        .valueOf(enable_cache_member));
0540:                            } else if (node.getName().equals(
0541:                                    "enable_cache_post")) {
0542:                                node.setText(String.valueOf(enable_cache_post));
0543:                            } else if (node.getName().equals(
0544:                                    "enable_cache_thread")) {
0545:                                node.setText(String
0546:                                        .valueOf(enable_cache_thread));
0547:                            } else if (node.getName().equals(
0548:                                    "enable_cache_forum")) {
0549:                                node
0550:                                        .setText(String
0551:                                                .valueOf(enable_cache_forum));
0552:                            } else if (node.getName().equals(
0553:                                    "enable_cache_category")) {
0554:                                node.setText(String
0555:                                        .valueOf(enable_cache_category));
0556:
0557:                            } else if (node.getName().equals(
0558:                                    "enable_passwordless_auth")) {
0559:                                node.setText(String
0560:                                        .valueOf(enable_passwordless_auth));
0561:                            } else if (node.getName().equals(
0562:                                    "enable_login_info_in_cookie")) {
0563:                                node.setText(String
0564:                                        .valueOf(enable_login_info_in_cookie));
0565:                            } else if (node.getName().equals(
0566:                                    "enable_login_info_in_session")) {
0567:                                node.setText(String
0568:                                        .valueOf(enable_login_info_in_session));
0569:                            } else if (node.getName().equals(
0570:                                    "enable_login_info_in_realm")) {
0571:                                node.setText(String
0572:                                        .valueOf(enable_login_info_in_realm));
0573:                            } else if (node.getName().equals(
0574:                                    "enable_login_info_in_customization")) {
0575:                                node
0576:                                        .setText(String
0577:                                                .valueOf(enable_login_info_in_customization));
0578:                            } else if (node.getName().equals(
0579:                                    "enable_check_invalid_session")) {
0580:                                node.setText(String
0581:                                        .valueOf(enable_check_invalid_session));
0582:                            } else if (node.getName().equals(
0583:                                    "require_activation")) {
0584:                                node
0585:                                        .setText(String
0586:                                                .valueOf(require_activation));
0587:                            } else if (node.getName().equals("enable_login")) {
0588:                                node.setText(String.valueOf(enable_login));
0589:                            } else if (node.getName().equals(
0590:                                    "enable_new_member")) {
0591:                                node.setText(String.valueOf(enable_new_member));
0592:                            } else if (node.getName().equals("enable_new_post")) {
0593:                                node.setText(String.valueOf(enable_new_post));
0594:                            } else if (node.getName().equals("enable_rss")) {
0595:                                node.setText(String.valueOf(enable_rss));
0596:                            } else if (node.getName().equals("enable_watch")) {
0597:                                node.setText(String.valueOf(enable_watch));
0598:                            } else if (node.getName().equals(
0599:                                    "enable_attachment")) {
0600:                                node.setText(String.valueOf(enable_attachment));
0601:                            } else if (node.getName().equals("enable_avatar")) {
0602:                                node.setText(String.valueOf(enable_avatar));
0603:                            } else if (node.getName().equals("enable_emoticon")) {
0604:                                node.setText(String.valueOf(enable_emoticon));
0605:                            } else if (node.getName().equals("enable_captcha")) {
0606:                                node.setText(String.valueOf(enable_captcha));
0607:                            } else if (node.getName().equals(
0608:                                    "enable_portal_like_index_page")) {
0609:                                node
0610:                                        .setText(String
0611:                                                .valueOf(enable_portal_like_index_page));
0612:
0613:                            } else if (node.getName().equals("enable_search")) {
0614:                                node.setText(String.valueOf(enable_search));
0615:                            } else if (node.getName().equals(
0616:                                    "enable_online_users")) {
0617:                                node.setText(String
0618:                                        .valueOf(enable_online_users));
0619:                            } else if (node.getName().equals(
0620:                                    "enable_duplicate_onlineusers")) {
0621:                                node.setText(String
0622:                                        .valueOf(enable_duplicate_onlineusers));
0623:                            } else if (node.getName().equals(
0624:                                    "enable_invisible_users")) {
0625:                                node.setText(String
0626:                                        .valueOf(enable_invisible_users));
0627:                            } else if (node.getName().equals(
0628:                                    "enable_listmembers")) {
0629:                                node
0630:                                        .setText(String
0631:                                                .valueOf(enable_listmembers));
0632:                            } else if (node.getName().equals(
0633:                                    "enable_show_last_login_of_current_member")) {
0634:                                node
0635:                                        .setText(String
0636:                                                .valueOf(enable_show_last_login_of_current_member));
0637:                            } else if (node.getName().equals(
0638:                                    "enable_show_last_login")) {
0639:                                node.setText(String
0640:                                        .valueOf(enable_show_last_login));
0641:                            } else if (node.getName().equals(
0642:                                    "enable_auto_watching")) {
0643:                                node.setText(String
0644:                                        .valueOf(enable_auto_watching));
0645:                            } else if (node.getName().equals(
0646:                                    "enable_show_birthday")) {
0647:                                node.setText(String
0648:                                        .valueOf(enable_show_birthday));
0649:                            } else if (node.getName().equals(
0650:                                    "enable_show_gender")) {
0651:                                node
0652:                                        .setText(String
0653:                                                .valueOf(enable_show_gender));
0654:                            } else if (node.getName().equals(
0655:                                    "enable_show_address")) {
0656:                                node.setText(String
0657:                                        .valueOf(enable_show_address));
0658:                            } else if (node.getName()
0659:                                    .equals("enable_show_city")) {
0660:                                node.setText(String.valueOf(enable_show_city));
0661:                            } else if (node.getName().equals(
0662:                                    "enable_show_state")) {
0663:                                node.setText(String.valueOf(enable_show_state));
0664:                            } else if (node.getName().equals(
0665:                                    "enable_show_country")) {
0666:                                node.setText(String
0667:                                        .valueOf(enable_show_country));
0668:                            } else if (node.getName().equals(
0669:                                    "enable_show_phone")) {
0670:                                node.setText(String.valueOf(enable_show_phone));
0671:                            } else if (node.getName().equals(
0672:                                    "enable_show_mobile")) {
0673:                                node
0674:                                        .setText(String
0675:                                                .valueOf(enable_show_mobile));
0676:                            } else if (node.getName().equals(
0677:                                    "enable_show_career")) {
0678:                                node
0679:                                        .setText(String
0680:                                                .valueOf(enable_show_career));
0681:                            } else if (node.getName().equals(
0682:                                    "enable_show_homepage")) {
0683:                                node.setText(String
0684:                                        .valueOf(enable_show_homepage));
0685:                            } else if (node.getName().equals(
0686:                                    "enable_show_cool_link_1")) {
0687:                                node.setText(String
0688:                                        .valueOf(enable_show_cool_link_1));
0689:                            } else if (node.getName().equals(
0690:                                    "enable_show_cool_link_2")) {
0691:                                node.setText(String
0692:                                        .valueOf(enable_show_cool_link_2));
0693:                            } else if (node.getName().equals(
0694:                                    "enable_show_yahoo")) {
0695:                                node.setText(String.valueOf(enable_show_yahoo));
0696:                            } else if (node.getName().equals("enable_show_aol")) {
0697:                                node.setText(String.valueOf(enable_show_aol));
0698:                            } else if (node.getName()
0699:                                    .equals(" enable_show_msn")) {
0700:                                node.setText(String.valueOf(enable_show_msn));
0701:                            } else if (node.getName().equals("enable_show_icq")) {
0702:                                node.setText(String.valueOf(enable_show_icq));
0703:                            } else if (node.getName().equals(
0704:                                    "enable_show_join_date")) {
0705:                                node.setText(String
0706:                                        .valueOf(enable_show_join_date));
0707:                            } else if (node.getName().equals(
0708:                                    "enable_show_post_count")) {
0709:                                node.setText(String
0710:                                        .valueOf(enable_show_post_count));
0711:                            } else if (node.getName().equals(
0712:                                    "enable_show_online_status")) {
0713:                                node.setText(String
0714:                                        .valueOf(enable_show_online_status));
0715:                            } else if (node.getName().equals(
0716:                                    "enable_show_lastname")) {
0717:                                node.setText(String
0718:                                        .valueOf(enable_show_lastname));
0719:                            } else if (node.getName().equals(
0720:                                    "enable_show_firstname")) {
0721:                                node.setText(String
0722:                                        .valueOf(enable_show_firstname));
0723:                            } else if (node.getName().equals(
0724:                                    "enable_show_view_count")) {
0725:                                node.setText(String
0726:                                        .valueOf(enable_show_view_count));
0727:                            } else if (node.getName().equals(
0728:                                    "enable_show_email")) {
0729:                                node.setText(String.valueOf(enable_show_email));
0730:                            } else if (node.getName().equals(
0731:                                    "enable_use_popup_menu_in_viewthread")) {
0732:                                node
0733:                                        .setText(String
0734:                                                .valueOf(enable_use_popup_menu_in_viewthread));
0735:                            } else if (node.getName().equals(
0736:                                    "enable_split_thread")) {
0737:                                node.setText(String
0738:                                        .valueOf(enable_split_thread));
0739:                            } else if (node.getName().equals(
0740:                                    "enable_listunansweredthreads")) {
0741:                                node.setText(String
0742:                                        .valueOf(enable_listunansweredthreads));
0743:                            } else if (node.getName().equals(
0744:                                    "enable_list_users_browsing_thread")) {
0745:                                node
0746:                                        .setText(String
0747:                                                .valueOf(enable_list_users_browsing_thread));
0748:                            } else if (node
0749:                                    .getName()
0750:                                    .equals(
0751:                                            "enable_email_to_admin_content_with_censored_words")) {
0752:                                node
0753:                                        .setText(String
0754:                                                .valueOf(enable_email_to_admin_content_with_censored_words));
0755:                            } else if (node.getName().equals(
0756:                                    "enable_guest_view_listusers")) {
0757:                                node.setText(String
0758:                                        .valueOf(enable_guest_view_listusers));
0759:                            } else if (node
0760:                                    .getName()
0761:                                    .equals(
0762:                                            "only_normal_thread_type_in_active_threads")) {
0763:                                node
0764:                                        .setText(String
0765:                                                .valueOf(only_normal_thread_type_in_active_threads));
0766:                            } else if (node.getName().equals(
0767:                                    "send_watchmail_as_html")) {
0768:                                node.setText(String
0769:                                        .valueOf(send_watchmail_as_html));
0770:                            } else if (node.getName().equals(
0771:                                    "enable_easy_watching")) {
0772:                                node.setText(String
0773:                                        .valueOf(enable_easy_watching));
0774:                            } else if (node.getName().equals(
0775:                                    "enable_send_watch_mail_of_my_own_post")) {
0776:                                node
0777:                                        .setText(String
0778:                                                .valueOf(enable_send_watch_mail_of_my_own_post));
0779:                            } else if (node.getName().equals(
0780:                                    "enable_private_message")) {
0781:                                node.setText(String
0782:                                        .valueOf(enable_private_message));
0783:                            } else if (node.getName().equals(
0784:                                    "enable_public_message")) {
0785:                                node.setText(String
0786:                                        .valueOf(enable_public_message));
0787:                            } else if (node.getName().equals(
0788:                                    "enable_message_attachment")) {
0789:                                node.setText(String
0790:                                        .valueOf(enable_message_attachment));
0791:                            } else if (node.getName().equals(
0792:                                    "enable_most_active_threads")) {
0793:                                node.setText(String
0794:                                        .valueOf(enable_most_active_threads));
0795:                            } else if (node.getName().equals(
0796:                                    "enable_most_active_members")) {
0797:                                node.setText(String
0798:                                        .valueOf(enable_most_active_members));
0799:                            } else if (node.getName().equals(
0800:                                    "enable_site_statistics_overview")) {
0801:                                node
0802:                                        .setText(String
0803:                                                .valueOf(enable_site_statistics_overview));
0804:                            } else if (node.getName().equals(
0805:                                    "enable_admin_can_change_password")) {
0806:                                node
0807:                                        .setText(String
0808:                                                .valueOf(enable_admin_can_change_password));
0809:                            } else if (node.getName().equals(
0810:                                    "enable_guest_view_image_attachment")) {
0811:                                node
0812:                                        .setText(String
0813:                                                .valueOf(enable_guest_view_image_attachment));
0814:                            } else if (node.getName().equals(
0815:                                    "enable_expanse_category_tree_by_default")) {
0816:                                node
0817:                                        .setText(String
0818:                                                .valueOf(enable_expanse_category_tree_by_default));
0819:                            } else if (node.getName().equals(
0820:                                    "default_watch_option")) {
0821:                                node.setText(String
0822:                                        .valueOf(default_watch_option));
0823:                            } else if (node.getName().equals(
0824:                                    "default_moderation_option")) {
0825:                                node.setText(String
0826:                                        .valueOf(default_moderation_option));
0827:                            } else if (node.getName().equals(
0828:                                    "enable_encrypt_password_on_browser")) {
0829:                                node
0830:                                        .setText(String
0831:                                                .valueOf(enable_encrypt_password_on_browser));
0832:                            } else if (node.getName().equals(
0833:                                    "enable_external_user_database")) {
0834:                                node
0835:                                        .setText(String
0836:                                                .valueOf(enable_external_user_database));
0837:                            } else if (node.getName().equals(
0838:                                    "days_to_show_recent_members")) {
0839:                                node.setText(String
0840:                                        .valueOf(days_to_show_recent_members));
0841:                            } else if (node.getName().equals(
0842:                                    "enable_list_new_members_in_recent_days")) {
0843:                                node
0844:                                        .setText(String
0845:                                                .valueOf(enable_list_new_members_in_recent_days));
0846:                            } else if (node.getName().equals(
0847:                                    "enable_list_users_browsing_forum")) {
0848:                                node
0849:                                        .setText(String
0850:                                                .valueOf(enable_list_users_browsing_forum));
0851:                            } else if (node.getName().equals(
0852:                                    "enable_email_threatening_content")) {
0853:                                node
0854:                                        .setText(String
0855:                                                .valueOf(enable_email_threatening_content));
0856:                            } else if (node.getName().equals("have_internet")) {
0857:                                node.setText(String.valueOf(have_internet));
0858:                            } else if (node.getName()
0859:                                    .equals("event_log_locale")) {
0860:                                node.setText(String.valueOf(event_log_locale));
0861:                            } else if (node.getName().equals(
0862:                                    "default_category_id")) {
0863:                                node.setText(String
0864:                                        .valueOf(default_category_id));
0865:                            } else if (node.getName().equals(
0866:                                    "default_watch_type")) {
0867:                                node
0868:                                        .setText(String
0869:                                                .valueOf(default_watch_type));
0870:                            } else if (node.getName().equals(
0871:                                    "default_status_of_registered_member")) {
0872:                                node
0873:                                        .setText(String
0874:                                                .valueOf(default_status_of_registered_member));
0875:                            } else if (node.getName().equals(
0876:                                    "enable_register_rule")) {
0877:                                node.setText(String
0878:                                        .valueOf(enable_register_rule));
0879:
0880:                                //  children of image_thumbnail
0881:                            } else if (node.getName().equals("image_thumbnail")) {
0882:                                Element el = (Element) node;
0883:                                for (int k = 0; k < el.nodeCount(); k++) {
0884:
0885:                                    Node childNode = el.node(k);
0886:                                    if (childNode.getNodeTypeName().equals(
0887:                                            "Element")) {
0888:
0889:                                        if (childNode.getName()
0890:                                                .equals("enable")) {
0891:                                            childNode
0892:                                                    .setText(String
0893:                                                            .valueOf(enable_image_thumbnail));
0894:                                        } else if (childNode.getName().equals(
0895:                                                "width")) {
0896:                                            if (enable_image_thumbnail) {
0897:                                                childNode
0898:                                                        .setText(String
0899:                                                                .valueOf(image_thumbnail_width));
0900:                                            }
0901:                                        } else if (childNode.getName().equals(
0902:                                                "height")) {
0903:                                            if (enable_image_thumbnail) {
0904:                                                childNode
0905:                                                        .setText(String
0906:                                                                .valueOf(image_thumbnail_height));
0907:                                            }
0908:                                        }
0909:                                    }
0910:                                }
0911:
0912:                                // children of mvnforumfactoryconfig
0913:                            } else if (node.getName().equals(
0914:                                    "member_implementation")) {
0915:                                node.setText(member_implementation);
0916:                            } else if (node.getName().equals(
0917:                                    "onlineuser_implementation")) {
0918:                                node.setText(onlineuser_implementation);
0919:                            } else if (node.getName().equals(
0920:                                    "authenticator_implementation")) {
0921:                                node.setText(authenticator_implementation);
0922:                            } else if (node.getName().equals(
0923:                                    "requestprocessor_implementation")) {
0924:                                node.setText(requestprocessor_implementation);
0925:                            } else if (node.getName().equals(
0926:                                    "lucene_analyzer_implementation")) {
0927:                                node.setText(lucene_analyzer_implementation);
0928:                            } else if (node.getName().equals(
0929:                                    "mvnforum_service_implementation")) {
0930:                                node.setText(mvnforum_service_implementation);
0931:                            } else if (node.getName().equals(
0932:                                    "mvn_auth_service_implementation")) {
0933:                                node.setText(mvn_auth_service_implementation);
0934:                            }
0935:                        }
0936:                    }
0937:                }
0938:
0939:                saveDocument(document, strPathName + "mvnforum.xml");
0940:                MVNForumConfig.reload();
0941:                request.setAttribute("step", "1");
0942:            }
0943:
0944:            public void updateConfigStepTwo(GenericRequest request)
0945:                    throws BadInputException, DocumentException, IOException,
0946:                    DatabaseException, AuthenticationException {
0947:
0948:                SecurityUtil.checkHttpPostMethod(request);
0949:
0950:                OnlineUser onlineUser = onlineUserManager
0951:                        .getOnlineUser(request);
0952:                MVNForumPermission permission = onlineUser.getPermission();
0953:                permission.ensureCanAdminSystem();
0954:
0955:                int max_private_message = GenericParamUtil
0956:                        .getParameterUnsignedInt(request, "max_private_message");
0957:                String max_message_attachment_size = GenericParamUtil
0958:                        .getParameterSafe(request,
0959:                                "max_message_attachment_size", true);
0960:                String max_attachment_size = GenericParamUtil.getParameterSafe(
0961:                        request, "max_attachment_size", true);
0962:                int max_favorite_thread = GenericParamUtil
0963:                        .getParameterUnsignedInt(request, "max_favorite_thread");
0964:                int max_edit_days = GenericParamUtil.getParameterUnsignedInt(
0965:                        request, "max_edit_days");
0966:                int max_attach_days = GenericParamUtil.getParameterUnsignedInt(
0967:                        request, "max_attach_days");
0968:                int max_delete_days = GenericParamUtil.getParameterUnsignedInt(
0969:                        request, "max_delete_days");
0970:                int rows_per_page = GenericParamUtil.getParameterUnsignedInt(
0971:                        request, "rows_per_page");
0972:                int rows_per_rss = GenericParamUtil.getParameterUnsignedInt(
0973:                        request, "rows_per_rss");
0974:                int hot_topic_threshold = GenericParamUtil
0975:                        .getParameterUnsignedInt(request, "hot_topic_threshold");
0976:
0977:                int max_http_requests_per_hour_per_ip = GenericParamUtil
0978:                        .getParameterUnsignedInt(request,
0979:                                "max_http_requests_per_hour_per_ip");
0980:                int max_posts_per_hour_per_ip = GenericParamUtil
0981:                        .getParameterUnsignedInt(request,
0982:                                "max_posts_per_hour_per_ip");
0983:                int max_members_per_hour_per_ip = GenericParamUtil
0984:                        .getParameterUnsignedInt(request,
0985:                                "max_members_per_hour_per_ip");
0986:                int max_logins_per_hour_per_ip = GenericParamUtil
0987:                        .getParameterUnsignedInt(request,
0988:                                "max_logins_per_hour_per_ip");
0989:                int max_messages_per_hour_per_ip = GenericParamUtil
0990:                        .getParameterUnsignedInt(request,
0991:                                "max_messages_per_hour_per_ip");
0992:                int max_password_days = GenericParamUtil
0993:                        .getParameterUnsignedInt(request, "max_password_days");
0994:                int max_posts_per_hour_per_member = GenericParamUtil
0995:                        .getParameterUnsignedInt(request,
0996:                                "max_posts_per_hour_per_member");
0997:
0998:                int max_chars_in_short_summary = GenericParamUtil
0999:                        .getParameterUnsignedInt(request,
1000:                                "max_chars_in_short_summary");
1001:                int max_chars_in_long_summary = GenericParamUtil
1002:                        .getParameterUnsignedInt(request,
1003:                                "max_chars_in_long_summary");
1004:                int max_chars_in_rss = GenericParamUtil
1005:                        .getParameterUnsignedInt(request, "max_chars_in_rss");
1006:
1007:                boolean enable_backup_on_server = GenericParamUtil
1008:                        .getParameterBoolean(request, "enable_backup_on_server");
1009:                int max_import_size = GenericParamUtil.getParameterUnsignedInt(
1010:                        request, "max_import_size");
1011:
1012:                String strPathName = FileUtil.getServletClassesPath();
1013:                SAXReader reader = new SAXReader();
1014:                Document document = reader.read(new File(strPathName
1015:                        + "mvnforum.xml"));
1016:                Element root = document.getRootElement();
1017:
1018:                // iterate through child elements of root
1019:                for (Iterator i = root.elementIterator("mvnforumconfig"); i
1020:                        .hasNext();) {
1021:                    Element element = (Element) i.next();
1022:                    for (int j = 0, size = element.nodeCount(); j < size; j++) {
1023:                        Node node = element.node(j);
1024:                        if (node.getNodeTypeName().equals("Element")) {
1025:                            if (node.getName().equals("max_private_message")) {
1026:                                node.setText(String
1027:                                        .valueOf(max_private_message));
1028:                            } else if (node.getName().equals(
1029:                                    "max_message_attachment_size")) {
1030:                                node.setText(max_message_attachment_size);
1031:                            } else if (node.getName().equals(
1032:                                    "max_attachment_size")) {
1033:                                node.setText(max_attachment_size);
1034:                            } else if (node.getName().equals(
1035:                                    "max_favorite_thread")) {
1036:                                node.setText(String
1037:                                        .valueOf(max_favorite_thread));
1038:                            } else if (node.getName().equals("max_edit_days")) {
1039:                                node.setText(String.valueOf(max_edit_days));
1040:                            } else if (node.getName().equals("max_attach_days")) {
1041:                                node.setText(String.valueOf(max_attach_days));
1042:                            } else if (node.getName().equals("max_delete_days")) {
1043:                                node.setText(String.valueOf(max_delete_days));
1044:                            } else if (node.getName().equals("rows_per_page")) {
1045:                                node.setText(String.valueOf(rows_per_page));
1046:                            } else if (node.getName().equals("rows_per_rss")) {
1047:                                node.setText(String.valueOf(rows_per_rss));
1048:                            } else if (node.getName().equals(
1049:                                    "hot_topic_threshold")) {
1050:                                node.setText(String
1051:                                        .valueOf(hot_topic_threshold));
1052:
1053:                            } else if (node.getName().equals(
1054:                                    "max_http_requests_per_hour_per_ip")) {
1055:                                node
1056:                                        .setText(String
1057:                                                .valueOf(max_http_requests_per_hour_per_ip));
1058:                            } else if (node.getName().equals(
1059:                                    "max_posts_per_hour_per_ip")) {
1060:                                node.setText(String
1061:                                        .valueOf(max_posts_per_hour_per_ip));
1062:                            } else if (node.getName().equals(
1063:                                    "max_members_per_hour_per_ip")) {
1064:                                node.setText(String
1065:                                        .valueOf(max_members_per_hour_per_ip));
1066:                            } else if (node.getName().equals(
1067:                                    "max_logins_per_hour_per_ip")) {
1068:                                node.setText(String
1069:                                        .valueOf(max_logins_per_hour_per_ip));
1070:                            } else if (node.getName().equals(
1071:                                    "max_messages_per_hour_per_ip")) {
1072:                                node.setText(String
1073:                                        .valueOf(max_messages_per_hour_per_ip));
1074:                            } else if (node.getName().equals(
1075:                                    "max_password_days")) {
1076:                                node.setText(String.valueOf(max_password_days));
1077:                            } else if (node.getName().equals(
1078:                                    "max_posts_per_hour_per_member")) {
1079:                                node
1080:                                        .setText(String
1081:                                                .valueOf(max_posts_per_hour_per_member));
1082:
1083:                            } else if (node.getName().equals(
1084:                                    "max_chars_in_short_summary")) {
1085:                                node.setText(String
1086:                                        .valueOf(max_chars_in_short_summary));
1087:                            } else if (node.getName().equals(
1088:                                    "max_chars_in_long_summary")) {
1089:                                node.setText(String
1090:                                        .valueOf(max_chars_in_long_summary));
1091:                            } else if (node.getName()
1092:                                    .equals("max_chars_in_rss")) {
1093:                                node.setText(String.valueOf(max_chars_in_rss));
1094:
1095:                            } else if (node.getName().equals(
1096:                                    "enable_backup_on_server")) {
1097:                                node.setText(String
1098:                                        .valueOf(enable_backup_on_server));
1099:                            } else if (node.getName().equals("max_import_size")) {
1100:                                node.setText(String.valueOf(max_import_size));
1101:                            }
1102:                        }
1103:                    }
1104:                }
1105:                saveDocument(document, strPathName + "mvnforum.xml");
1106:                MVNForumConfig.reload();
1107:                request.setAttribute("step", "2");
1108:            }
1109:
1110:            public void updateConfigStepThree(GenericRequest request)
1111:                    throws BadInputException, DocumentException, IOException,
1112:                    DatabaseException, AuthenticationException {
1113:
1114:                SecurityUtil.checkHttpPostMethod(request);
1115:
1116:                OnlineUser onlineUser = onlineUserManager
1117:                        .getOnlineUser(request);
1118:                MVNForumPermission permission = onlineUser.getPermission();
1119:                permission.ensureCanAdminSystem();
1120:
1121:                boolean require_register_firstname = GenericParamUtil
1122:                        .getParameterBoolean(request,
1123:                                "require_register_firstname");
1124:                boolean require_register_lastname = GenericParamUtil
1125:                        .getParameterBoolean(request,
1126:                                "require_register_lastname");
1127:                boolean require_register_gender = GenericParamUtil
1128:                        .getParameterBoolean(request, "require_register_gender");
1129:                boolean require_register_birthday = GenericParamUtil
1130:                        .getParameterBoolean(request,
1131:                                "require_register_birthday");
1132:                boolean require_register_address = GenericParamUtil
1133:                        .getParameterBoolean(request,
1134:                                "require_register_address");
1135:                boolean require_register_city = GenericParamUtil
1136:                        .getParameterBoolean(request, "require_register_city");
1137:                boolean require_register_state = GenericParamUtil
1138:                        .getParameterBoolean(request, "require_register_state");
1139:                boolean require_register_country = GenericParamUtil
1140:                        .getParameterBoolean(request,
1141:                                "require_register_country");
1142:                boolean require_register_phone = GenericParamUtil
1143:                        .getParameterBoolean(request, "require_register_phone");
1144:                boolean require_register_mobile = GenericParamUtil
1145:                        .getParameterBoolean(request, "require_register_mobile");
1146:                boolean require_register_career = GenericParamUtil
1147:                        .getParameterBoolean(request, "require_register_career");
1148:                boolean require_register_homepage = GenericParamUtil
1149:                        .getParameterBoolean(request,
1150:                                "require_register_homepage");
1151:                boolean require_register_yahoo = GenericParamUtil
1152:                        .getParameterBoolean(request, "require_register_yahoo");
1153:                boolean require_register_aol = GenericParamUtil
1154:                        .getParameterBoolean(request, "require_register_aol");
1155:                boolean require_register_icq = GenericParamUtil
1156:                        .getParameterBoolean(request, "require_register_icq");
1157:                boolean require_register_msn = GenericParamUtil
1158:                        .getParameterBoolean(request, "require_register_msn");
1159:                boolean require_register_link_1 = GenericParamUtil
1160:                        .getParameterBoolean(request, "require_register_link_1");
1161:                boolean require_register_link_2 = GenericParamUtil
1162:                        .getParameterBoolean(request, "require_register_link_2");
1163:
1164:                String strPathName = FileUtil.getServletClassesPath();
1165:                SAXReader reader = new SAXReader();
1166:                Document document = reader.read(new File(strPathName
1167:                        + "mvnforum.xml"));
1168:
1169:                Element root = document.getRootElement();
1170:
1171:                // iterate through child elements of root
1172:                for (Iterator i = root.elementIterator("mvnforumconfig"); i
1173:                        .hasNext();) {
1174:                    Element element = (Element) i.next();
1175:                    for (int j = 0, size = element.nodeCount(); j < size; j++) {
1176:                        Node node = element.node(j);
1177:                        if (node.getNodeTypeName().equals("Element")) {
1178:                            if (node.getName().equals(
1179:                                    "require_register_firstname")) {
1180:                                node.setText(String
1181:                                        .valueOf(require_register_firstname));
1182:                            } else if (node.getName().equals(
1183:                                    "require_register_lastname")) {
1184:                                node.setText(String
1185:                                        .valueOf(require_register_lastname));
1186:                            } else if (node.getName().equals(
1187:                                    "require_register_gender")) {
1188:                                node.setText(String
1189:                                        .valueOf(require_register_gender));
1190:                            } else if (node.getName().equals(
1191:                                    "require_register_birthday")) {
1192:                                node.setText(String
1193:                                        .valueOf(require_register_birthday));
1194:                            } else if (node.getName().equals(
1195:                                    "require_register_address")) {
1196:                                node.setText(String
1197:                                        .valueOf(require_register_address));
1198:                            } else if (node.getName().equals(
1199:                                    "require_register_city")) {
1200:                                node.setText(String
1201:                                        .valueOf(require_register_city));
1202:                            } else if (node.getName().equals(
1203:                                    "require_register_state")) {
1204:                                node.setText(String
1205:                                        .valueOf(require_register_state));
1206:                            } else if (node.getName().equals(
1207:                                    "require_register_country")) {
1208:                                node.setText(String
1209:                                        .valueOf(require_register_country));
1210:                            } else if (node.getName().equals(
1211:                                    "require_register_phone")) {
1212:                                node.setText(String
1213:                                        .valueOf(require_register_phone));
1214:                            } else if (node.getName().equals(
1215:                                    "require_register_mobile")) {
1216:                                node.setText(String
1217:                                        .valueOf(require_register_mobile));
1218:                            } else if (node.getName().equals(
1219:                                    "require_register_career")) {
1220:                                node.setText(String
1221:                                        .valueOf(require_register_career));
1222:                            } else if (node.getName().equals(
1223:                                    "require_register_homepage")) {
1224:                                node.setText(String
1225:                                        .valueOf(require_register_homepage));
1226:                            } else if (node.getName().equals(
1227:                                    "require_register_yahoo")) {
1228:                                node.setText(String
1229:                                        .valueOf(require_register_yahoo));
1230:                            } else if (node.getName().equals(
1231:                                    "require_register_aol")) {
1232:                                node.setText(String
1233:                                        .valueOf(require_register_aol));
1234:                            } else if (node.getName().equals(
1235:                                    "require_register_icq")) {
1236:                                node.setText(String
1237:                                        .valueOf(require_register_icq));
1238:                            } else if (node.getName().equals(
1239:                                    "require_register_msn")) {
1240:                                node.setText(String
1241:                                        .valueOf(require_register_msn));
1242:                            } else if (node.getName().equals(
1243:                                    "require_register_link_1")) {
1244:                                node.setText(String
1245:                                        .valueOf(require_register_link_1));
1246:                            } else if (node.getName().equals(
1247:                                    "require_register_link_2")) {
1248:                                node.setText(String
1249:                                        .valueOf(require_register_link_2));
1250:                            }
1251:                        }
1252:                    }
1253:                }
1254:                saveDocument(document, strPathName + "mvnforum.xml");
1255:                MVNForumConfig.reload();
1256:                request.setAttribute("step", "3");
1257:            }
1258:
1259:            public void updateConfigMVNCore(GenericRequest request)
1260:                    throws BadInputException, DocumentException, IOException,
1261:                    DatabaseException, AuthenticationException {
1262:
1263:                SecurityUtil.checkHttpPostMethod(request);
1264:
1265:                OnlineUser onlineUser = onlineUserManager
1266:                        .getOnlineUser(request);
1267:                MVNForumPermission permission = onlineUser.getPermission();
1268:                permission.ensureCanAdminSystem();
1269:
1270:                boolean isUseDatasource = GenericParamUtil.getParameterBoolean(
1271:                        request, "use_datasource");
1272:
1273:                int database_type = 0;
1274:                String driver_class_name = "";
1275:                String database_url = "";
1276:                String database_user = "";
1277:                String database_password = "";
1278:                int max_connection = 0;
1279:                int max_time_to_wait = 0;
1280:                int minutes_between_refresh = 0;
1281:                String datasource_name = "";
1282:
1283:                if (isUseDatasource == false) {
1284:                    database_type = GenericParamUtil.getParameterUnsignedInt(
1285:                            request, "database_type");
1286:                    driver_class_name = GenericParamUtil.getParameterSafe(
1287:                            request, "driver_class_name", true);
1288:                    database_url = GenericParamUtil.getParameterSafe(request,
1289:                            "database_url", true);
1290:                    database_user = GenericParamUtil.getParameterSafe(request,
1291:                            "database_user", true);
1292:                    database_password = GenericParamUtil.getParameterSafe(
1293:                            request, "database_password", false);
1294:                    max_connection = GenericParamUtil.getParameterUnsignedInt(
1295:                            request, "max_connection");
1296:                    max_time_to_wait = GenericParamUtil
1297:                            .getParameterUnsignedInt(request,
1298:                                    "max_time_to_wait");
1299:                    minutes_between_refresh = GenericParamUtil
1300:                            .getParameterUnsignedInt(request,
1301:                                    "minutes_between_refresh");
1302:                } else {
1303:                    datasource_name = GenericParamUtil.getParameterSafe(
1304:                            request, "datasource_name", false);
1305:                }
1306:
1307:                String default_mail_from = GenericParamUtil.getParameterEmail(
1308:                        request, "default_mail_from");
1309:
1310:                boolean isReceiveUseMailsource = GenericParamUtil
1311:                        .getParameterBoolean(request,
1312:                                "receive_mail_enable_mail_source");
1313:                boolean isSendUseMailsource = GenericParamUtil
1314:                        .getParameterBoolean(request,
1315:                                "send_mail_enable_mail_source");
1316:                boolean isSendUseSMTPServer = GenericParamUtil
1317:                        .getParameterBoolean(request,
1318:                                "send_mail_use_embeded_smtp_mail_server");
1319:
1320:                String receive_mail_source_name = "";
1321:                String receive_mail_server = "";
1322:                String receive_mail_username = "";
1323:                String receive_mail_password = "";
1324:                int receive_mail_port = 0;
1325:
1326:                String send_mail_source_name = "";
1327:                String send_mail_server = "";
1328:                String send_mail_username = "";
1329:                String send_mail_password = "";
1330:                int send_mail_port = 0;
1331:
1332:                if (isReceiveUseMailsource == false) {
1333:                    receive_mail_server = GenericParamUtil.getParameterSafe(
1334:                            request, "receive_mail_server", true);
1335:                    receive_mail_username = GenericParamUtil.getParameterSafe(
1336:                            request, "receive_mail_username", false);
1337:                    receive_mail_password = GenericParamUtil.getParameterSafe(
1338:                            request, "receive_mail_password", false);
1339:                    receive_mail_port = GenericParamUtil
1340:                            .getParameterUnsignedInt(request,
1341:                                    "receive_mail_port");
1342:                } else {
1343:                    receive_mail_source_name = GenericParamUtil
1344:                            .getParameterSafe(request,
1345:                                    "receive_mail_source_name", true);
1346:                }
1347:                if (isSendUseSMTPServer) {
1348:                    // do nothing
1349:                } else if (isSendUseMailsource) {
1350:                    send_mail_source_name = GenericParamUtil.getParameterSafe(
1351:                            request, "send_mail_source_name", true);
1352:                } else {
1353:                    send_mail_server = GenericParamUtil.getParameterSafe(
1354:                            request, "send_mail_server", true);
1355:                    send_mail_username = GenericParamUtil.getParameterSafe(
1356:                            request, "send_mail_username", false);
1357:                    send_mail_password = GenericParamUtil.getParameterSafe(
1358:                            request, "send_mail_password", false);
1359:                    send_mail_port = GenericParamUtil.getParameterUnsignedInt(
1360:                            request, "send_mail_port");
1361:                }
1362:
1363:                String context_path = GenericParamUtil.getParameterSafe(
1364:                        request, "context_path", false);
1365:                String server_path = GenericParamUtil.getParameterSafe(request,
1366:                        "server_path", true);
1367:
1368:                int server_hour_offset = GenericParamUtil.getParameterInt(
1369:                        request, "server_hour_offset");
1370:                if (server_hour_offset < -13 || server_hour_offset > 13) {
1371:                    server_hour_offset = 0;
1372:                }
1373:
1374:                String blocked_user_agent = GenericParamUtil.getParameterSafe(
1375:                        request, "blocked_user_agent", false);
1376:                String blocked_ip = GenericParamUtil.getParameterSafe(request,
1377:                        "blocked_ip", false);
1378:
1379:                boolean enable_link_nofollow = GenericParamUtil
1380:                        .getParameterBoolean(request, "enable_link_nofollow");
1381:                boolean enable_encode_url = GenericParamUtil
1382:                        .getParameterBoolean(request, "enable_encode_url");
1383:
1384:                String portal_type = GenericParamUtil.getParameterSafe(request,
1385:                        "portal_type", true);
1386:                String mvncoreservice_implementation = GenericParamUtil
1387:                        .getParameterSafe(request,
1388:                                "mvncoreservice_implementation", true);
1389:
1390:                String mailinterceptor_implementation = GenericParamUtil
1391:                        .getParameterSafe(request,
1392:                                "mailinterceptor_implementation", false);
1393:                String contentinterceptor_implementation = GenericParamUtil
1394:                        .getParameterSafe(request,
1395:                                "contentinterceptor_implementation", false);
1396:                String loginidinterceptor_implementation = GenericParamUtil
1397:                        .getParameterSafe(request,
1398:                                "loginidinterceptor_implementation", false);
1399:                String passwordinterceptor_implementation = GenericParamUtil
1400:                        .getParameterSafe(request,
1401:                                "passwordinterceptor_implementation", false);
1402:
1403:                // Now checking the validity of value
1404:                Locale locale = onlineUser.getLocale();
1405:
1406:                MyUtil.checkClassName(locale, driver_class_name, true);
1407:
1408:                MyUtil.checkClassName(locale, mvncoreservice_implementation,
1409:                        true);
1410:
1411:                MyUtil.checkClassName(locale, mailinterceptor_implementation,
1412:                        false);
1413:                MyUtil.checkClassName(locale,
1414:                        contentinterceptor_implementation, false);
1415:                MyUtil.checkClassName(locale,
1416:                        loginidinterceptor_implementation, false);
1417:                MyUtil.checkClassName(locale,
1418:                        passwordinterceptor_implementation, false);
1419:
1420:                // End checking, now save the value
1421:                String strPathName = FileUtil.getServletClassesPath();
1422:                SAXReader reader = new SAXReader();
1423:                Document document = reader.read(new File(strPathName
1424:                        + "mvncore.xml"));
1425:
1426:                boolean enable_mvnforum = GenericParamUtil.getParameterBoolean(
1427:                        request, "enable_mvnforum");
1428:                boolean enable_mvncms = GenericParamUtil.getParameterBoolean(
1429:                        request, "enable_mvncms");
1430:
1431:                Element root = document.getRootElement();
1432:                for (int i = 0; i < root.nodeCount(); i++) {
1433:
1434:                    Node node = root.node(i);
1435:                    if (node.getNodeTypeName().equals("Element")) {
1436:                        if (node.getName().equals("plugin_options")) {
1437:
1438:                            Element el = (Element) node;
1439:                            for (int j = 0; j < el.nodeCount(); j++) {
1440:
1441:                                Node childNode = el.node(j);
1442:                                if (childNode.getNodeTypeName().equals(
1443:                                        "Element")) {
1444:
1445:                                    if (childNode.getName().equals(
1446:                                            "enable_mvnforum")) {
1447:                                        childNode.setText(String
1448:                                                .valueOf(enable_mvnforum));
1449:                                    } else if (childNode.getName().equals(
1450:                                            "enable_mvncms")) {
1451:                                        childNode.setText(String
1452:                                                .valueOf(enable_mvncms));
1453:                                    }
1454:                                }
1455:                            }
1456:                        } else if (node.getName().equals("dboptions")) {
1457:
1458:                            Element el = (Element) node;
1459:                            for (int j = 0; j < el.nodeCount(); j++) {
1460:
1461:                                Node childNode = el.node(j);
1462:                                if (childNode.getNodeTypeName().equals(
1463:                                        "Element")) {
1464:                                    if (childNode.getName().equals(
1465:                                            "database_type")) {
1466:                                        childNode.setText(String
1467:                                                .valueOf(database_type));
1468:                                    } else if (childNode.getName().equals(
1469:                                            "use_datasource")) {
1470:                                        childNode.setText(String
1471:                                                .valueOf(isUseDatasource));
1472:                                    } else if (childNode.getName().equals(
1473:                                            "driver_class_name")) {
1474:                                        if (isUseDatasource == false) {
1475:                                            childNode
1476:                                                    .setText(driver_class_name);
1477:                                        }
1478:                                    } else if (childNode.getName().equals(
1479:                                            "database_url")) {
1480:                                        if (isUseDatasource == false) {
1481:                                            childNode.setText(database_url);
1482:                                        }
1483:                                    } else if (childNode.getName().equals(
1484:                                            "database_user")) {
1485:                                        if (isUseDatasource == false) {
1486:                                            childNode.setText(database_user);
1487:                                        }
1488:                                    } else if (childNode.getName().equals(
1489:                                            "database_password")) {
1490:                                        if (isUseDatasource == false) {
1491:                                            childNode
1492:                                                    .setText(database_password);
1493:                                        }
1494:                                    } else if (childNode.getName().equals(
1495:                                            "max_connection")) {
1496:                                        if (isUseDatasource == false) {
1497:                                            childNode.setText(String
1498:                                                    .valueOf(max_connection));
1499:                                        }
1500:                                    } else if (childNode.getName().equals(
1501:                                            "max_time_to_wait")) {
1502:                                        if (isUseDatasource == false) {
1503:                                            childNode.setText(String
1504:                                                    .valueOf(max_time_to_wait));
1505:                                        }
1506:                                    } else if (childNode.getName().equals(
1507:                                            "minutes_between_refresh")) {
1508:                                        if (isUseDatasource == false) {
1509:                                            childNode
1510:                                                    .setText(String
1511:                                                            .valueOf(minutes_between_refresh));
1512:                                        }
1513:                                    } else if (childNode.getName().equals(
1514:                                            "datasource_name")) {
1515:                                        if (isUseDatasource) {
1516:                                            childNode.setText(datasource_name);
1517:                                        }
1518:                                    }
1519:                                }
1520:                            }
1521:                        } else if (node.getName().equals("mailoptions")) {
1522:
1523:                            Element el = (Element) node;
1524:                            for (int j = 0; j < el.nodeCount(); j++) {
1525:
1526:                                Node childNode = el.node(j);
1527:                                if (childNode.getNodeTypeName().equals(
1528:                                        "Element")) {
1529:                                    if (childNode.getName().equals(
1530:                                            "default_mail_from")) {
1531:                                        childNode.setText(String
1532:                                                .valueOf(default_mail_from));
1533:                                    } else if (childNode.getName().equals(
1534:                                            "receive_mail")) {
1535:
1536:                                        Element subEl = (Element) childNode;
1537:                                        for (int k = 0; k < subEl.nodeCount(); k++) {
1538:
1539:                                            Node grandChildNode = subEl.node(k);
1540:                                            if (grandChildNode
1541:                                                    .getNodeTypeName().equals(
1542:                                                            "Element")) {
1543:                                                if (grandChildNode
1544:                                                        .getName()
1545:                                                        .equals(
1546:                                                                "enable_mail_source")) {
1547:                                                    grandChildNode
1548:                                                            .setText(String
1549:                                                                    .valueOf(isReceiveUseMailsource));
1550:                                                } else if (grandChildNode
1551:                                                        .getName().equals(
1552:                                                                "mail_server")) {
1553:                                                    if (isReceiveUseMailsource == false) {
1554:                                                        grandChildNode
1555:                                                                .setText(receive_mail_server);
1556:                                                    }
1557:                                                } else if (grandChildNode
1558:                                                        .getName().equals(
1559:                                                                "username")) {
1560:                                                    if (isReceiveUseMailsource == false) {
1561:                                                        grandChildNode
1562:                                                                .setText(receive_mail_username);
1563:                                                    }
1564:                                                } else if (grandChildNode
1565:                                                        .getName().equals(
1566:                                                                "password")) {
1567:                                                    if (isReceiveUseMailsource == false) {
1568:                                                        grandChildNode
1569:                                                                .setText(receive_mail_password);
1570:                                                    }
1571:                                                } else if (grandChildNode
1572:                                                        .getName().equals(
1573:                                                                "port")) {
1574:                                                    if (isReceiveUseMailsource == false) {
1575:                                                        grandChildNode
1576:                                                                .setText(String
1577:                                                                        .valueOf(receive_mail_port));
1578:                                                    }
1579:                                                } else if (grandChildNode
1580:                                                        .getName()
1581:                                                        .equals(
1582:                                                                "mail_source_name")) {
1583:                                                    if (isReceiveUseMailsource) {
1584:                                                        grandChildNode
1585:                                                                .setText(String
1586:                                                                        .valueOf(receive_mail_source_name));
1587:                                                    }
1588:                                                }
1589:                                            }
1590:                                        }
1591:                                    } else if (childNode.getName().equals(
1592:                                            "send_mail")) {
1593:
1594:                                        Element subEl = (Element) childNode;
1595:                                        for (int k = 0; k < subEl.nodeCount(); k++) {
1596:
1597:                                            Node grandChildNode = subEl.node(k);
1598:                                            if (grandChildNode
1599:                                                    .getNodeTypeName().equals(
1600:                                                            "Element")) {
1601:                                                if (isSendUseSMTPServer) {
1602:                                                    if (grandChildNode
1603:                                                            .getName()
1604:                                                            .equals(
1605:                                                                    "use_embeded_smtp_mail_server")) {
1606:                                                        grandChildNode
1607:                                                                .setText(String
1608:                                                                        .valueOf(isSendUseSMTPServer));
1609:                                                    }
1610:                                                } else {
1611:                                                    if (grandChildNode
1612:                                                            .getName()
1613:                                                            .equals(
1614:                                                                    "use_embeded_smtp_mail_server")) {
1615:                                                        grandChildNode
1616:                                                                .setText(String
1617:                                                                        .valueOf(isSendUseSMTPServer));
1618:                                                    } else if (grandChildNode
1619:                                                            .getName()
1620:                                                            .equals(
1621:                                                                    "enable_mail_source")) {
1622:                                                        grandChildNode
1623:                                                                .setText(String
1624:                                                                        .valueOf(isSendUseMailsource));
1625:                                                    } else if (grandChildNode
1626:                                                            .getName()
1627:                                                            .equals(
1628:                                                                    "mail_server")) {
1629:                                                        if (isSendUseMailsource == false) {
1630:                                                            grandChildNode
1631:                                                                    .setText(send_mail_server);
1632:                                                        }
1633:                                                    } else if (grandChildNode
1634:                                                            .getName().equals(
1635:                                                                    "username")) {
1636:                                                        if (isSendUseMailsource == false) {
1637:                                                            grandChildNode
1638:                                                                    .setText(send_mail_username);
1639:                                                        }
1640:                                                    } else if (grandChildNode
1641:                                                            .getName().equals(
1642:                                                                    "password")) {
1643:                                                        if (isSendUseMailsource == false) {
1644:                                                            grandChildNode
1645:                                                                    .setText(send_mail_password);
1646:                                                        }
1647:                                                    } else if (grandChildNode
1648:                                                            .getName().equals(
1649:                                                                    "port")) {
1650:                                                        if (isSendUseMailsource == false) {
1651:                                                            grandChildNode
1652:                                                                    .setText(String
1653:                                                                            .valueOf(send_mail_port));
1654:                                                        }
1655:                                                    } else if (grandChildNode
1656:                                                            .getName()
1657:                                                            .equals(
1658:                                                                    "mail_source_name")) {
1659:                                                        if (isSendUseMailsource) {
1660:                                                            grandChildNode
1661:                                                                    .setText(String
1662:                                                                            .valueOf(send_mail_source_name));
1663:                                                        }
1664:                                                    }
1665:                                                }
1666:                                            }
1667:                                        }
1668:                                    }
1669:                                }
1670:                            }
1671:                            //end mailoptions
1672:                        } else if (node.getName().equals("paramoptions")) {
1673:
1674:                            Element el = (Element) node;
1675:                            for (int j = 0; j < el.nodeCount(); j++) {
1676:
1677:                                Node childNode = el.node(j);
1678:                                if (childNode.getNodeTypeName().equals(
1679:                                        "Element")) {
1680:
1681:                                    if (childNode.getName().equals(
1682:                                            "context_path")) {
1683:                                        childNode.setText(context_path);
1684:                                    } else if (childNode.getName().equals(
1685:                                            "server_path")) {
1686:                                        childNode.setText(server_path);
1687:                                    }
1688:                                }
1689:                            }
1690:                        } else if (node.getName().equals("dateoptions")) {
1691:                            Element el = ((Element) node)
1692:                                    .element("server_hour_offset");
1693:                            el.setText(String.valueOf(server_hour_offset));
1694:                        } else if (node.getName().equals("useragentoptions")) {
1695:                            Element el = ((Element) node)
1696:                                    .element("blocked_user_agent");
1697:                            el.setText(String.valueOf(blocked_user_agent));
1698:                        } else if (node.getName().equals("ipoptions")) {
1699:                            Element el = ((Element) node).element("blocked_ip");
1700:                            el.setText(String.valueOf(blocked_ip));
1701:                        } else if (node.getName().equals("mvncoreconfig")) {
1702:
1703:                            Element el = (Element) node;
1704:                            for (int j = 0; j < el.nodeCount(); j++) {
1705:
1706:                                Node childNode = el.node(j);
1707:                                if (childNode.getNodeTypeName().equals(
1708:                                        "Element")) {
1709:
1710:                                    if (childNode.getName().equals(
1711:                                            "enable_link_nofollow")) {
1712:                                        childNode.setText(String
1713:                                                .valueOf(enable_link_nofollow));
1714:                                    } else if (childNode.getName().equals(
1715:                                            "enable_encode_url")) {
1716:                                        childNode.setText(String
1717:                                                .valueOf(enable_encode_url));
1718:                                    } else if (childNode.getName().equals(
1719:                                            "portal_type")) {
1720:                                        childNode.setText(portal_type);
1721:                                    } else if (childNode.getName().equals(
1722:                                            "mvncoreservice_implementation")) {
1723:                                        childNode
1724:                                                .setText(mvncoreservice_implementation);
1725:                                    }
1726:                                }
1727:                            }
1728:                        } else if (node.getName().equals("interceptor")) {
1729:
1730:                            Element el = (Element) node;
1731:                            for (int j = 0; j < el.nodeCount(); j++) {
1732:
1733:                                Node childNode = el.node(j);
1734:                                if (childNode.getNodeTypeName().equals(
1735:                                        "Element")) {
1736:
1737:                                    if (childNode.getName().equals(
1738:                                            "mailinterceptor_implementation")) {
1739:                                        childNode
1740:                                                .setText(mailinterceptor_implementation);
1741:                                    } else if (childNode
1742:                                            .getName()
1743:                                            .equals(
1744:                                                    "contentinterceptor_implementation")) {
1745:                                        childNode
1746:                                                .setText(contentinterceptor_implementation);
1747:                                    } else if (childNode
1748:                                            .getName()
1749:                                            .equals(
1750:                                                    "loginidinterceptor_implementation")) {
1751:                                        childNode
1752:                                                .setText(loginidinterceptor_implementation);
1753:                                    } else if (childNode
1754:                                            .getName()
1755:                                            .equals(
1756:                                                    "passwordinterceptor_implementation")) {
1757:                                        childNode
1758:                                                .setText(passwordinterceptor_implementation);
1759:                                    }
1760:                                }
1761:                            }
1762:                        }
1763:                    }
1764:                }
1765:
1766:                saveDocument(document, strPathName + "mvncore.xml");
1767:                MVNCoreConfig.reload();
1768:                request.setAttribute("action", "updatemvncore");
1769:            }
1770:
1771:            public void updateUrlPattern(GenericRequest request)
1772:                    throws BadInputException, DocumentException, IOException,
1773:                    AuthenticationException, DatabaseException {
1774:
1775:                SecurityUtil.checkHttpPostMethod(request);
1776:
1777:                OnlineUser onlineUser = onlineUserManager
1778:                        .getOnlineUser(request);
1779:                MVNForumPermission permission = onlineUser.getPermission();
1780:                permission.ensureCanAdminSystem();
1781:
1782:                String admin_url = GenericParamUtil.getParameterSafe(request,
1783:                        "admin_url", true);
1784:                String user_url = GenericParamUtil.getParameterSafe(request,
1785:                        "user_url", true);
1786:
1787:                String strPathName = FileUtil.getServletClassesPath();
1788:                SAXReader reader = new SAXReader();
1789:                String xmlFilePath = strPathName + "mvnforum.xml";
1790:                Document document = reader.read(new File(xmlFilePath));
1791:
1792:                Element root = document.getRootElement();
1793:                for (int i = 0; i < root.nodeCount(); i++) {
1794:                    Node node = root.node(i);
1795:                    //log.debug("Node " + i + " = " + node.getName());
1796:                    if (node.getNodeTypeName().equals("Element")) {
1797:                        if (node.getName().equals("adminmoduleconfig")) {
1798:                            Node subElement = ((Element) node)
1799:                                    .element("url_pattern");
1800:                            //log.debug("sub element " + subElement);
1801:                            subElement.setText(admin_url);
1802:                        } else if (node.getName().equals("usermoduleconfig")) {
1803:                            Node subElement = ((Element) node)
1804:                                    .element("url_pattern");
1805:                            //log.debug("sub element " + subElement);
1806:                            subElement.setText(user_url);
1807:                        }
1808:                    }
1809:                }
1810:
1811:                saveDocument(document, xmlFilePath);
1812:                request.setAttribute("action", "updateurls");
1813:            }
1814:
1815:            public void configBackupProcess(GenericRequest request)
1816:                    throws IOException, DatabaseException,
1817:                    AuthenticationException {
1818:
1819:                OnlineUser onlineUser = onlineUserManager
1820:                        .getOnlineUser(request);
1821:                MVNForumPermission permission = onlineUser.getPermission();
1822:                permission.ensureCanAdminSystem();
1823:
1824:                String servletClassPath = FileUtil.getServletClassesPath();
1825:                EnvironmentService environmentService = MvnCoreServiceFactory
1826:                        .getMvnCoreService().getEnvironmentService();
1827:
1828:                String mvnCoreFileName = servletClassPath + File.separator
1829:                        + "mvncore.xml";
1830:                String mvnForumFileName = servletClassPath + File.separator
1831:                        + "mvnforum.xml";
1832:                String mvnForumEntFileName = servletClassPath + File.separator
1833:                        + "mvnforum_enterprise.xml";
1834:                String mvnAdFileName = servletClassPath + File.separator
1835:                        + "mvnad.xml";
1836:                String mvnCmsFileName = servletClassPath + File.separator
1837:                        + "mvncms.xml";
1838:
1839:                String pattern = "yyyy-MM-dd_HH-mm-ss";
1840:                String nowDesc = DateUtil.format(new Date(), pattern);
1841:                String newMvnCoreFileName = servletClassPath + File.separator
1842:                        + "mvncore_" + nowDesc + ".xml";
1843:                String newMvnForumFileName = servletClassPath + File.separator
1844:                        + "mvnforum_" + nowDesc + ".xml";
1845:                String newMvnForumEntFileName = servletClassPath
1846:                        + File.separator + "mvnforum_enterprise" + nowDesc
1847:                        + ".xml";
1848:                String newMvnAdFileName = servletClassPath + File.separator
1849:                        + "mvnad" + nowDesc + ".xml";
1850:                String newMvnCmsFileName = servletClassPath + File.separator
1851:                        + "mvncms" + nowDesc + ".xml";
1852:
1853:                // We don't have to check files here, we check it in FileUtil.copyFile
1854:                FileUtil.copyFile(mvnCoreFileName, newMvnCoreFileName, false);
1855:                FileUtil.copyFile(mvnForumFileName, newMvnForumFileName, false);
1856:
1857:                if (environmentService.isEnterprise()) {
1858:                    FileUtil.copyFile(mvnForumEntFileName,
1859:                            newMvnForumEntFileName, false);
1860:                    File newMvnForumEntFile = new File(newMvnForumEntFileName);
1861:                    request.setAttribute("MvnForumEntFileName",
1862:                            newMvnForumEntFile.getAbsolutePath());
1863:                }
1864:                if (environmentService.isMVNAd()) {
1865:                    FileUtil.copyFile(mvnAdFileName, newMvnAdFileName, false);
1866:                    File newMvnAdFile = new File(newMvnAdFileName);
1867:                    request.setAttribute("MvnAdFileName", newMvnAdFile
1868:                            .getAbsolutePath());
1869:                }
1870:                if (environmentService.isMVNCMS()) {
1871:                    FileUtil.copyFile(mvnCmsFileName, newMvnCmsFileName, false);
1872:                    File newMvnCmsFile = new File(newMvnCmsFileName);
1873:                    request.setAttribute("MvnCmsFileName", newMvnCmsFile
1874:                            .getAbsolutePath());
1875:                }
1876:
1877:                File newMVNCoreFile = new File(newMvnCoreFileName);
1878:                File newMVNForumFile = new File(newMvnForumFileName);
1879:
1880:                request.setAttribute("MvnCoreFileName", newMVNCoreFile
1881:                        .getAbsolutePath());
1882:                request.setAttribute("MvnForumFileName", newMVNForumFile
1883:                        .getAbsolutePath());
1884:                request.setAttribute("step", "Backup");
1885:            }
1886:
1887:            private void saveDocument(Document doc, String fileName)
1888:                    throws IOException {
1889:                XMLWriter writer = new XMLWriter(new FileWriter(fileName));
1890:                writer.write(doc);
1891:                writer.close();
1892:            }
1893:
1894:            public void prepareEditTemplate(GenericRequest request)
1895:                    throws AuthenticationException, DatabaseException,
1896:                    IOException, FileNotFoundException, BadInputException {
1897:
1898:                OnlineUser onlineUser = onlineUserManager
1899:                        .getOnlineUser(request);
1900:                MVNForumPermission permission = onlineUser.getPermission();
1901:                permission.ensureCanAdminSystem();
1902:
1903:                String templateName = GenericParamUtil.getParameterSafe(
1904:                        request, "template", false);
1905:                StringUtil.checkGoodName(templateName);
1906:                String subject = "";
1907:                String body = "";
1908:                final String SUBJECT_SUFFIX = "_subject";
1909:                final String BODY_SUFFIX = "_body";
1910:                final String EXTENSION = ".ftl";
1911:
1912:                if (templateName.equals("")) {
1913:                    templateName = MVNForumGlobal.TEMPLATE_SENDACTIVATECODE_PREFIX;
1914:                }
1915:
1916:                // check for valid input
1917:                if ((templateName
1918:                        .equals(MVNForumGlobal.TEMPLATE_FORGOTPASSWORD_PREFIX) == false)
1919:                        && (templateName
1920:                                .equals(MVNForumGlobal.TEMPLATE_SENDACTIVATECODE_PREFIX) == false)
1921:                        && (templateName
1922:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_DIGEST_PREFIX) == false)
1923:                        && (templateName
1924:                                .equals(MVNForumGlobal.TEMPLATE_SENDMAIL_BECAUSE_CENSORED_POST_PREFIX) == false)
1925:                        && (templateName
1926:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_SINGLE_PREFIX) == false)
1927:                        && (templateName
1928:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_SINGLE_PREFIX) == false)
1929:                        && (templateName
1930:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_DIGEST_PREFIX) == false)) {
1931:                    throw new AssertionError("Does not accept invalid input: "
1932:                            + templateName);
1933:                }
1934:
1935:                String templateDir = MVNForumConfig.getTemplateDir();
1936:                String subjectFileName = templateDir + File.separator
1937:                        + templateName + SUBJECT_SUFFIX;
1938:                String bodyFileName = templateDir + File.separator
1939:                        + templateName + BODY_SUFFIX;
1940:
1941:                if (MVNForumConfig.getSendWatchMailAsHTML()
1942:                        && templateName
1943:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_DIGEST_PREFIX)) {
1944:                    bodyFileName += "_html";
1945:                }
1946:
1947:                subjectFileName += EXTENSION;
1948:                bodyFileName += EXTENSION;
1949:
1950:                //        subject = new String(FileUtil.getBytes(new FileInputStream(subjectFileName)), "UTF-8");
1951:                //        body    = new String(FileUtil.getBytes(new FileInputStream(bodyFileName)), "UTF-8");
1952:                subject = FileUtil.readFile(subjectFileName, "UTF-8");
1953:                body = FileUtil.readFile(bodyFileName, "UTF-8");
1954:
1955:                request.setAttribute("TemplateSubject", subject);
1956:                request.setAttribute("TemplateBody", body);
1957:            }
1958:
1959:            public void processEditTemplate(GenericRequest request)
1960:                    throws DatabaseException, AuthenticationException,
1961:                    IOException, FileNotFoundException, BadInputException,
1962:                    TemplateException {
1963:
1964:                SecurityUtil.checkHttpPostMethod(request);
1965:
1966:                OnlineUser onlineUser = onlineUserManager
1967:                        .getOnlineUser(request);
1968:                MVNForumPermission permission = onlineUser.getPermission();
1969:                permission.ensureCanAdminSystem();
1970:
1971:                final String SUBJECT_SUFFIX = "_subject";
1972:                final String BODY_SUFFIX = "_body";
1973:                final String EXTENSION = ".ftl";
1974:
1975:                String templateName = GenericParamUtil.getParameterSafe(
1976:                        request, "template", true);
1977:                StringUtil.checkGoodName(templateName);
1978:
1979:                // checking valid input here
1980:                if ((templateName
1981:                        .equals(MVNForumGlobal.TEMPLATE_FORGOTPASSWORD_PREFIX) == false)
1982:                        && (templateName
1983:                                .equals(MVNForumGlobal.TEMPLATE_SENDACTIVATECODE_PREFIX) == false)
1984:                        && (templateName
1985:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_DIGEST_PREFIX) == false)
1986:                        && (templateName
1987:                                .equals(MVNForumGlobal.TEMPLATE_SENDMAIL_BECAUSE_CENSORED_POST_PREFIX) == false)
1988:                        && (templateName
1989:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_SINGLE_PREFIX) == false)
1990:                        && (templateName
1991:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_SINGLE_PREFIX) == false)
1992:                        && (templateName
1993:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_DIGEST_PREFIX) == false)) {
1994:                    throw new AssertionError("Does not accept invalid input: "
1995:                            + templateName);
1996:                }
1997:
1998:                String subject = GenericParamUtil.getParameter(request,
1999:                        "subject", true);
2000:                String body = GenericParamUtil.getParameter(request, "body",
2001:                        true);
2002:
2003:                String templateDir = MVNForumConfig.getTemplateDir();
2004:                String subjectFileName = templateDir + File.separator
2005:                        + templateName + SUBJECT_SUFFIX;
2006:                String bodyFileName = templateDir + File.separator
2007:                        + templateName + BODY_SUFFIX;
2008:
2009:                if (MVNForumConfig.getSendWatchMailAsHTML()
2010:                        && templateName
2011:                                .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_DIGEST_PREFIX)) {
2012:                    bodyFileName += "_html";
2013:                }
2014:
2015:                subjectFileName += EXTENSION;
2016:                bodyFileName += EXTENSION;
2017:
2018:                // just for testing FreeMarker
2019:                SimpleHash root = new SimpleHash();
2020:                try {
2021:                    Configuration cfg = MVNForumConfig
2022:                            .getFreeMarkerConfiguration();
2023:                    if (templateName
2024:                            .equals(MVNForumGlobal.TEMPLATE_SENDACTIVATECODE_PREFIX)) {
2025:                        root.put("serverName", "");
2026:                        root.put("MVNForumInfo", "");
2027:                        root.put("activationUrl", "");
2028:                        root.put("memberName", "");
2029:                        root.put("activateCode", "");
2030:                    } else if (templateName
2031:                            .equals(MVNForumGlobal.TEMPLATE_FORGOTPASSWORD_PREFIX)) {
2032:                        root.put("serverName", "");
2033:                        root.put("MVNForumInfo", "");
2034:                        root.put("passwordResetUrl", "");
2035:                        root.put("memberName", "");
2036:                        root.put("currentTempPassword", "");
2037:                    } else if (templateName
2038:                            .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_DIGEST_PREFIX)) {
2039:                        root.put("lastSent", "");
2040:                        root.put("now", "");
2041:                        root.put("forumBase", "");
2042:
2043:                        ArrayList list = new ArrayList();
2044:                        SimpleHash subroot = new SimpleHash();
2045:                        subroot.put("leader", true);
2046:                        subroot.put("categoryName", "");
2047:                        subroot.put("forumName", "");
2048:                        subroot.put("threadTopic", "");
2049:                        subroot.put("memberName", "");
2050:                        subroot.put("lastPostMemberName", "");
2051:                        subroot.put("threadLastPostDate", "");
2052:                        subroot.put("threadUrl", "");
2053:                        list.add(subroot);
2054:
2055:                        root.put("threadWatchList", list);
2056:                    } else if (templateName
2057:                            .equals(MVNForumGlobal.TEMPLATE_SENDMAIL_BECAUSE_CENSORED_POST_PREFIX)) {
2058:                        root.put("postID", "");
2059:                        root.put("forumID", "");
2060:                        root.put("threadID", "");
2061:                        root.put("memberID", "");
2062:                        root.put("postURL", "");
2063:                    } else if (templateName
2064:                            .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_SINGLE_PREFIX)) {
2065:                        root.put("lastSent", "");
2066:                        root.put("now", "");
2067:                        root.put("forumBase", "");
2068:
2069:                        SimpleHash subRoot = new SimpleHash();
2070:                        subRoot.put("categoryName", "");
2071:                        subRoot.put("forumName", "");
2072:                        subRoot.put("threadTopic", "");
2073:                        subRoot.put("memberName", "");
2074:                        subRoot.put("lastPostMemberName", "");
2075:                        subRoot.put("threadLastPostDate", "");
2076:                        subRoot.put("threadUrl", "");
2077:                        subRoot.put("leader", true);
2078:
2079:                        ArrayList list = new ArrayList();
2080:                        list.add(subRoot);
2081:
2082:                        Iterator iter = list.iterator();
2083:
2084:                        root.put("threadWatch", iter.next());
2085:                    } else if (templateName
2086:                            .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_SINGLE_PREFIX)) {
2087:                        root.put("lastSent", "");
2088:                        root.put("now", "");
2089:                        root.put("forumBase", "");
2090:
2091:                        SimpleHash subRoot = new SimpleHash();
2092:                        subRoot.put("categoryName", "");
2093:                        subRoot.put("forumName", "");
2094:                        subRoot.put("threadTopic", "");
2095:                        subRoot.put("threadID", "");
2096:                        subRoot.put("memberReceiveMail", "");
2097:                        subRoot.put("memberName", "");
2098:                        subRoot.put("lastPostMemberName", "");
2099:                        subRoot.put("threadLastPostDate", "");
2100:                        subRoot.put("confirmedCode", "");
2101:                        subRoot.put("threadBodyLong", "");
2102:                        subRoot.put("threadBodyShort", "");
2103:                        subRoot.put("threadUrl", "");
2104:                        subRoot.put("leader", true);
2105:                        subRoot.put("haveConfirmedCode", true);
2106:
2107:                        ArrayList list = new ArrayList();
2108:                        list.add(subRoot);
2109:
2110:                        Iterator iter = list.iterator();
2111:
2112:                        root.put("threadWatch", iter.next());
2113:                    } else if (templateName
2114:                            .equals(MVNForumGlobal.TEMPLATE_WATCHMAIL_GATEWAY_DIGEST_PREFIX)) {
2115:                        root.put("lastSent", "");
2116:                        root.put("now", "");
2117:                        root.put("forumBase", "");
2118:
2119:                        SimpleHash subRoot = new SimpleHash();
2120:                        subRoot.put("categoryName", "");
2121:                        subRoot.put("forumName", "");
2122:                        subRoot.put("threadTopic", "");
2123:                        subRoot.put("threadID", "");
2124:                        subRoot.put("memberReceiveMail", "");
2125:                        subRoot.put("memberName", "");
2126:                        subRoot.put("lastPostMemberName", "");
2127:                        subRoot.put("threadLastPostDate", "");
2128:                        subRoot.put("confirmedCode", "");
2129:                        subRoot.put("threadBodyLong", "");
2130:                        subRoot.put("threadUrl", "");
2131:                        subRoot.put("leader", true);
2132:                        subRoot.put("haveConfirmedCode", true);
2133:                        subRoot.put("mailFrom", "");
2134:
2135:                        ArrayList list = new ArrayList();
2136:                        list.add(subRoot);
2137:
2138:                        root.put("threadWatchList", list);
2139:                    } else {
2140:                        AssertionUtil.doAssert(false,
2141:                                "Does not accept invalid input: "
2142:                                        + templateName);
2143:                    }
2144:                    StringReader subjectReader = new StringReader(subject);
2145:                    StringReader bodyReader = new StringReader(body);
2146:
2147:                    Template subjectTemplate = new Template("", subjectReader,
2148:                            cfg, "");
2149:                    StringWriter subjectWriter = new StringWriter(256);
2150:                    subjectTemplate.process(root, subjectWriter);
2151:
2152:                    Template bodyTemplate = new Template("", bodyReader, cfg,
2153:                            "");
2154:                    StringWriter bodyWriter = new StringWriter(1024);
2155:                    bodyTemplate.process(root, bodyWriter);
2156:                } catch (TemplateException ex) {
2157:                    throw ex;
2158:                }
2159:                FileUtil.writeFile(subject, subjectFileName, "UTF-8");
2160:                FileUtil.writeFile(body, bodyFileName, "UTF-8");
2161:
2162:                request.setAttribute("Successful", "true");
2163:                request.setAttribute("TemplateSubject", subject);
2164:                request.setAttribute("TemplateBody", body);
2165:            }
2166:
2167:            public void commitConfig(GenericRequest request)
2168:                    throws DatabaseException, AuthenticationException {
2169:
2170:                OnlineUser onlineUser = onlineUserManager
2171:                        .getOnlineUser(request);
2172:                MVNForumPermission permission = onlineUser.getPermission();
2173:                permission.ensureCanAdminSystem();
2174:
2175:                MVNForumConfig.reload();
2176:                MVNCoreConfig.reload();
2177:
2178:                MvnCoreServiceFactory.getMvnCoreService()
2179:                        .getEnvironmentService().overloadEnvironment();
2180:
2181:                request.setAttribute("action", "commit");
2182:            }
2183:
2184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.