001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/portal/tags/sakai_2-4-1/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/PDAHandler.java $
003: * $Id: PDAHandler.java 22583 2007-03-14 02:14:54Z csev@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006, 2007 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.portal.charon.handlers;
021:
022: import javax.servlet.http.HttpServletRequest;
023: import javax.servlet.http.HttpServletResponse;
024:
025: import org.sakaiproject.portal.api.Portal;
026: import org.sakaiproject.portal.api.PortalHandlerException;
027: import org.sakaiproject.portal.api.PortalRenderContext;
028: import org.sakaiproject.tool.api.Session;
029: import org.sakaiproject.util.Web;
030:
031: /**
032: * @author ieb
033: */
034: public class PDAHandler extends PageHandler {
035: public PDAHandler() {
036: urlFragment = "pda";
037: }
038:
039: @Override
040: public int doGet(String[] parts, HttpServletRequest req,
041: HttpServletResponse res, Session session)
042: throws PortalHandlerException {
043: if ((parts.length >= 2) && (parts[1].equals("pda"))) {
044: try {
045:
046: // /portal/pda/site-id
047: String siteId = null;
048: if (parts.length >= 3) {
049: siteId = parts[2];
050: }
051:
052: // This is a pop-up page - it does exactly the same as
053: // /portal/page
054: // /portal/pda/site-id/page/page-id
055: // 1 2 3 4
056: String pageId = null;
057: if ((parts.length == 5) && (parts[3].equals("page"))) {
058: doPage(req, res, session, parts[4], req
059: .getContextPath()
060: + req.getServletPath());
061: return END;
062: }
063:
064: // Tool resetting URL - clear state and forward to the real tool
065: // URL
066: // /portal/pda/site-id/tool-reset/toolId
067: // 0 1 2 3 4
068: String toolId = null;
069: if ((siteId != null) && (parts.length == 5)
070: && (parts[3].equals("tool-reset"))) {
071: toolId = parts[4];
072: String toolUrl = req.getContextPath() + "/pda/"
073: + siteId + "/tool"
074: + Web.makePath(parts, 4, parts.length);
075: String queryString = req.getQueryString();
076: if (queryString != null) {
077: toolUrl = toolUrl + "?" + queryString;
078: }
079: portalService.setResetState("true");
080: res.sendRedirect(toolUrl);
081: return RESET_DONE;
082: }
083:
084: // Tool after the reset
085: // /portal/pda/site-id/tool/toolId
086: if ((parts.length == 5) && (parts[3].equals("tool"))) {
087: toolId = parts[4];
088: }
089:
090: String forceLogout = req
091: .getParameter(Portal.PARAM_FORCE_LOGOUT);
092: if ("yes".equalsIgnoreCase(forceLogout)
093: || "true".equalsIgnoreCase(forceLogout)) {
094: portal.doLogout(req, res, session, "/pda");
095: return END;
096: }
097:
098: if (session.getUserId() == null) {
099: String forceLogin = req
100: .getParameter(Portal.PARAM_FORCE_LOGIN);
101: if ("yes".equalsIgnoreCase(forceLogin)
102: || "true".equalsIgnoreCase(forceLogin)) {
103: portal.doLogin(req, res, session, req
104: .getPathInfo(), false);
105: return END;
106: }
107: }
108:
109: PortalRenderContext rcontext = portal.includePortal(
110: req, res, session, siteId, toolId, req
111: .getContextPath()
112: + req.getServletPath(), "pda",
113: /* doPages */false, /* resetTools */true,
114: /* includeSummary */false, /* expandSite */
115: false);
116:
117: portal.sendResponse(rcontext, res, "pda", null);
118: return END;
119: } catch (Exception ex) {
120: throw new PortalHandlerException(ex);
121: }
122: } else {
123: return NEXT;
124: }
125: }
126:
127: }
|