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.portal.processor;
020:
021: import java.io.IOException;
022:
023: import javax.servlet.ServletException;
024: import javax.servlet.http.HttpServletRequest;
025: import javax.servlet.http.HttpServletResponse;
026:
027: import com.nabhinc.condition.AlwaysTrue;
028: import com.nabhinc.condition.Condition;
029: import com.nabhinc.portal.core.PortalEventMonitor;
030: import com.nabhinc.portal.core.PortalConstants;
031: import com.nabhinc.portal.core.PortalUtil;
032: import com.nabhinc.portal.core.SessionCache;
033: import com.nabhinc.portal.model.PortalApplicationView;
034: import com.nabhinc.portal.model.PortalConfiguration;
035: import com.nabhinc.portal.model.PortalPageState;
036: import com.nabhinc.util.StringUtil;
037:
038: /**
039: *
040: *
041: * @author Padmanabh Dabke
042: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
043: */
044: public class EditPageProcessor extends AdminAppPortalActionProcessor {
045: public void process(HttpServletRequest request,
046: HttpServletResponse response, SessionCache sCache,
047: PortalApplicationView portalAppView,
048: PortalPageState pageState, int startIndex,
049: String[] portalParams, String displayMode,
050: String targetWindowId, boolean isAJAXRequest)
051: throws ServletException, IOException {
052:
053: if (!isAJAXRequest) {
054: response.sendRedirect(pageState.getPageURL());
055: return;
056: } else if (request.getParameter("is_submit") == null) {
057: request.getRequestDispatcher("/admin/edit_page.jsp")
058: .forward(request, response);
059: } else {
060: if (request
061: .getParameter(PortalConstants.REMOVE_PASSWORD_PARAM) != null) {
062: pageState.portalPage.setPassword(null);
063: }
064: String password = request
065: .getParameter(PortalConstants.PASSWORD_PARAM);
066: if (StringUtil.isNotNullOrEmpty(password)) {
067: pageState.portalPage.setPassword(password);
068: }
069: String editPerm = request
070: .getParameter(PortalConstants.EDIT_PERM_TYPE_PARAM);
071: if (StringUtil.isNotNullOrEmpty(editPerm)) {
072: pageState.portalPage.setEditPermission(PortalUtil
073: .createCondition(request, editPerm,
074: PortalConstants.EDIT_ROLES_PARAM,
075: PortalConstants.EDIT_USERS_PARAM));
076: }
077: String viewPerm = request
078: .getParameter(PortalConstants.VIEW_PERM_TYPE_PARAM);
079: if (StringUtil.isNotNullOrEmpty(viewPerm)) {
080: pageState.portalPage.setViewPermission(PortalUtil
081: .createCondition(request, viewPerm,
082: PortalConstants.VIEW_ROLES_PARAM,
083: PortalConstants.VIEW_USERS_PARAM));
084:
085: Condition oldCondition = pageState.portalPage
086: .getViewPermission();
087: Condition newCondition = pageState.portalPage
088: .getViewPermission();
089: boolean oldFlag = oldCondition != null
090: && (!(oldCondition instanceof AlwaysTrue));
091: boolean newFlag = newCondition != null
092: && (!(newCondition instanceof AlwaysTrue));
093: if (oldFlag != newFlag) {
094: PortalEventMonitor monitor = PortalConfiguration
095: .getInstance().getEventMonitor();
096: if (monitor != null)
097: monitor.viewPermissionChanged(portalAppView
098: .getPortalApplication().getPath(),
099: pageState.portalPage.getIndex());
100: }
101:
102: }
103: String dPerm = request
104: .getParameter(PortalConstants.DELETE_PERM_TYPE_PARAM);
105: if (StringUtil.isNotNullOrEmpty(dPerm)) {
106: pageState.portalPage.setDeletePermission(PortalUtil
107: .createCondition(request, dPerm,
108: PortalConstants.DELETE_ROLES_PARAM,
109: PortalConstants.DELETE_USERS_PARAM));
110: }
111: }
112: }
113:
114: }
|