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.portal.core.PortalConstants;
028: import com.nabhinc.portal.core.PortalUtil;
029: import com.nabhinc.portal.core.SessionCache;
030: import com.nabhinc.portal.model.PortalApplicationView;
031: import com.nabhinc.portal.model.PortalPageState;
032: import com.nabhinc.portal.model.PortletWindow;
033:
034: public class ChangeWindowStateProcessor extends
035: BasePortalActionProcessor {
036: public void process(HttpServletRequest request,
037: HttpServletResponse response, SessionCache sCache,
038: PortalApplicationView portalAppView,
039: PortalPageState pageState, int startIndex,
040: String[] portalParams, String displayMode,
041: String targetWindowId, boolean isAJAXRequest)
042: throws ServletException, IOException {
043:
044: String newWindowState = null;
045:
046: if (portalParams.length > startIndex) {
047: targetWindowId = portalParams[startIndex];
048: startIndex++;
049: if (portalParams.length > startIndex) {
050: newWindowState = portalParams[startIndex];
051: startIndex++;
052: }
053: }
054:
055: if (targetWindowId == null || newWindowState == null) {
056: throw new ServletException(
057: "Malformed window state change URL.");
058: }
059: PortletWindow pWindow = pageState.portalPage
060: .getPortletWindow(targetWindowId);
061: if (pWindow == null) {
062: // response.setStatus(HttpServletResponse.SC_NOT_FOUND);
063: response.sendError(HttpServletResponse.SC_NOT_FOUND);
064: return;
065: }
066: boolean isDetached = displayMode
067: .equals(PortalConstants.DISPLAY_MODE_DETACHED);
068: String globalWindowId = pWindow.getId();
069: String oldDisplayMode = displayMode;
070: displayMode = PortalUtil.setupWindowState(isDetached,
071: newWindowState, request.getSession(), globalWindowId,
072: displayMode);
073:
074: if (!oldDisplayMode.equals(displayMode)) {
075: request.setAttribute(PortalConstants.CURRENT_DISPLAY_MODE,
076: displayMode);
077: if (displayMode.equals(PortalConstants.DISPLAY_MODE_NORMAL)) {
078: pageState.setNormalPageMode(request.getSession());
079: } else if (displayMode
080: .equals(PortalConstants.DISPLAY_MODE_MAXIMIZED)) {
081: pageState.setMaximizedPageMode(pWindow, request
082: .getSession());
083: }
084: if (!displayMode
085: .equals(PortalConstants.DISPLAY_MODE_DETACHED)) {
086: sCache.renderResponse
087: .setBaseURL(pageState.getPageURL());
088: }
089: }
090:
091: if (isAJAXRequest) {
092: PortalUtil.renderPortletWindow(request, response, pWindow,
093: portalAppView.getPortalApplication(), displayMode,
094: true);
095: } else {
096: ViewProcessor.getInstance().process(request, response,
097: sCache, portalAppView, pageState, startIndex,
098: portalParams, displayMode, targetWindowId,
099: isAJAXRequest);
100:
101: }
102:
103: }
104:
105: }
|