001: /*
002: * (C) Copyright 2000 - 2006 Nabh Information Systems, Inc.
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: *
018: */
019: package com.nabhinc.portlet.admin;
020:
021: import java.io.IOException;
022:
023: import javax.portlet.ActionRequest;
024: import javax.portlet.ActionResponse;
025: import javax.portlet.PortletException;
026:
027: import com.nabhinc.portal.api.PortalInformationStoreLocator;
028: import com.nabhinc.portal.model.PortalConfiguration;
029: import com.nabhinc.portlet.mvcportlet.core.ActionConfig;
030: import com.nabhinc.portlet.mvcportlet.core.ActionProcessor;
031: import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
032: import com.nabhinc.util.StringUtil;
033:
034: /**
035: *
036: *
037: * @author Padmanabh Dabke<br/>
038: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
039: */
040: public class PortalOptionsSaver extends BaseRequestProcessor implements
041: ActionProcessor {
042: @SuppressWarnings("unchecked")
043: public String process(ActionRequest request,
044: ActionResponse response, ActionConfig actionConfig)
045: throws PortletException, IOException {
046:
047: PortalConfiguration config = PortalConfiguration.getInstance();
048: config
049: .setAJAXDisabled(request
050: .getParameter(PortalAdminConstants.DISABLE_AJAX_PARAM) != null);
051: config
052: .setLoginCaptchaEnabled(request
053: .getParameter(PortalAdminConstants.LOGIN_CAPTCHA_PARAM) != null);
054: config
055: .setRegistrationCaptchaEnabled(request
056: .getParameter(PortalAdminConstants.REG_CAPTCHA_PARAM) != null);
057: config
058: .setRememberMe(request
059: .getParameter(PortalAdminConstants.REMEMBER_ME_PARAM) != null);
060: config
061: .setRememberUsername(request
062: .getParameter(PortalAdminConstants.REMEMBER_USER_NAME_PARAM) != null);
063: config
064: .setSecureConnectionSupported(request
065: .getParameter(PortalAdminConstants.SUPPORT_SSL_PARAM) != null);
066: config
067: .setSecureLogin(request
068: .getParameter(PortalAdminConstants.SECURE_LOGIN_PARAM) != null);
069: config
070: .setSelfRegistrationAllowed(request
071: .getParameter(PortalAdminConstants.ALLOW_SELF_REG_PARAM) != null);
072: config
073: .setSendUsername(request
074: .getParameter(PortalAdminConstants.SEND_USER_NAME_PARAM) != null);
075: config
076: .setShowLocaleIcons(request
077: .getParameter(PortalAdminConstants.SHOW_LOCALE_ICONS_PARAM) != null);
078:
079: if (StringUtil.isNullOrEmpty(request
080: .getParameter(PortalAdminConstants.TIMEOUT_PARAM))) {
081: config.setSessionTimeout(0);
082: } else {
083: config.setSessionTimeout(Integer.parseInt(request
084: .getParameter(PortalAdminConstants.TIMEOUT_PARAM)));
085: }
086:
087: String lang = "";
088: String country = "";
089: String defaultLocale = request
090: .getParameter(PortalAdminConstants.DEFAULT_LOCALE_PARAM);
091: if (StringUtil.isNotNullOrEmpty(defaultLocale)) {
092: int index = defaultLocale.indexOf("_");
093: if (index != -1) {
094: lang = defaultLocale.substring(0, index);
095: country = defaultLocale.substring(index + 1);
096: } else {
097: lang = defaultLocale;
098: }
099: }
100:
101: PortalConfiguration.LocaleConfig lc = new PortalConfiguration.LocaleConfig();
102: lc.lang = lang;
103: lc.country = country;
104: config.setDefaultLocaleConfig(lc);
105:
106: config.setPortalAdminEmail(request
107: .getParameter(PortalAdminConstants.ADMIN_EMAIL_PARAM));
108: config
109: .setPortalSecureURLPrefix(request
110: .getParameter(PortalAdminConstants.PORTAL_SECURE_URL_PREFIX_PARAM));
111: config
112: .setPortalURLPrefix(request
113: .getParameter(PortalAdminConstants.PORTAL_URL_PREFIX_PARAM));
114: config.setThemesDir(request
115: .getParameter(PortalAdminConstants.THEMES_DIR_PARAM));
116: config
117: .setWidePortlets(request
118: .getParameter(PortalAdminConstants.WIDE_PORTLETS_PARAM));
119:
120: /*
121: * Must uncomment the following two lines if the two fields are added to the UI.
122: config.setProtectedPortletRedirectURL(request.getParameter(PortalAdminConstants.PROTECTED_REDIRECT_PARAM));
123: config.setNotFoundPortlet(request.getParameter(PortalAdminConstants.NOT_FOUND_PORTLET_PARAM));
124: */
125:
126: PortalInformationStoreLocator.getPortalInformationStore()
127: .savePortalConfiguration(config);
128:
129: // Reset session parameters
130: actionConfig.getForm().cancel(request, response);
131:
132: return "success";
133: }
134:
135: }
|