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.PortletException;
024: import javax.portlet.RenderRequest;
025: import javax.portlet.RenderResponse;
026:
027: import com.nabhinc.core.Constants;
028: import com.nabhinc.portal.model.PortalConfiguration;
029: import com.nabhinc.portlet.mvcportlet.core.BaseRequestProcessor;
030: import com.nabhinc.portlet.mvcportlet.core.RenderConfig;
031: import com.nabhinc.portlet.mvcportlet.core.RenderProcessor;
032:
033: /**
034: *
035: *
036: * @author Padmanabh Dabke<br/>
037: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
038: */
039: public class PortalOptionsInitializer extends BaseRequestProcessor
040: implements RenderProcessor {
041: @SuppressWarnings("unchecked")
042: public String process(RenderRequest request,
043: RenderResponse response, RenderConfig actionConfig)
044: throws PortletException, IOException {
045:
046: PortalConfiguration config = PortalConfiguration.getInstance();
047: if (request.getParameter(Constants.FORM_SUBMIT_PARAMETER) != null)
048: return "success";
049: String on = "on";
050:
051: if (config.isAJAXDisabled())
052: request.setAttribute(
053: PortalAdminConstants.DISABLE_AJAX_PARAM, on);
054: if (config.isLoginCaptchaEnabled())
055: request.setAttribute(
056: PortalAdminConstants.LOGIN_CAPTCHA_PARAM, on);
057: if (config.isRegistrationCaptchaEnabled())
058: request.setAttribute(
059: PortalAdminConstants.REG_CAPTCHA_PARAM, on);
060: if (config.isRememberMe())
061: request.setAttribute(
062: PortalAdminConstants.REMEMBER_ME_PARAM, on);
063: if (config.isRememberUsername())
064: request.setAttribute(
065: PortalAdminConstants.REMEMBER_USER_NAME_PARAM, on);
066: if (config.isSecureConnectionSupported())
067: request.setAttribute(
068: PortalAdminConstants.SUPPORT_SSL_PARAM, on);
069: if (config.isSecureLogin())
070: request.setAttribute(
071: PortalAdminConstants.SECURE_LOGIN_PARAM, on);
072: if (config.isSelfRegistrationAllowed())
073: request.setAttribute(
074: PortalAdminConstants.ALLOW_SELF_REG_PARAM, on);
075: if (config.isSendUsername())
076: request.setAttribute(
077: PortalAdminConstants.SEND_USER_NAME_PARAM, on);
078: if (config.isShowLocaleIcons())
079: request.setAttribute(
080: PortalAdminConstants.SHOW_LOCALE_ICONS_PARAM, on);
081:
082: int requestTimeout = config.getSessionTimeout();
083: if (requestTimeout != 0)
084: request.setAttribute(PortalAdminConstants.TIMEOUT_PARAM,
085: Integer.toString(requestTimeout));
086:
087: request.setAttribute(PortalAdminConstants.DEFAULT_LOCALE_PARAM,
088: config.getDefaultLocaleConfig().toString());
089:
090: request.setAttribute(PortalAdminConstants.ADMIN_EMAIL_PARAM,
091: config.getPortalAdminEmail());
092: request.setAttribute(
093: PortalAdminConstants.NOT_FOUND_PORTLET_PARAM, config
094: .getNotFoundPortlet());
095: request.setAttribute(
096: PortalAdminConstants.PORTAL_SECURE_URL_PREFIX_PARAM,
097: config.getPortalSecureURLPrefix());
098: request.setAttribute(
099: PortalAdminConstants.PORTAL_URL_PREFIX_PARAM, config
100: .getPortalURLPrefix());
101: request.setAttribute(PortalAdminConstants.THEMES_DIR_PARAM,
102: config.getThemesDir());
103: request.setAttribute(PortalAdminConstants.WIDE_PORTLETS_PARAM,
104: config.getWidePortlets());
105: request.setAttribute(
106: PortalAdminConstants.PROTECTED_REDIRECT_PARAM, config
107: .getProtectedPortletRedirectURL());
108:
109: return "success";
110: }
111:
112: }
|