001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/portal/tags/sakai_2-4-1/portal-impl/impl/src/java/org/sakaiproject/portal/charon/handlers/HelpHandler.java $
003: * $Id: HelpHandler.java 29143 2007-04-19 01:10:38Z ajpoland@iupui.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 java.io.IOException;
023:
024: import javax.servlet.http.HttpServletRequest;
025: import javax.servlet.http.HttpServletResponse;
026:
027: import org.sakaiproject.component.cover.ServerConfigurationService;
028: import org.sakaiproject.portal.api.Portal;
029: import org.sakaiproject.portal.api.PortalHandlerException;
030: import org.sakaiproject.tool.api.ActiveTool;
031: import org.sakaiproject.tool.api.Session;
032: import org.sakaiproject.tool.api.ToolException;
033: import org.sakaiproject.tool.cover.ActiveToolManager;
034: import org.sakaiproject.util.Web;
035:
036: /**
037: *
038: * @author ieb
039: * @since Sakai 2.4
040: * @version $Rev: 29143 $
041: *
042: */
043: public class HelpHandler extends BasePortalHandler {
044: public HelpHandler() {
045: urlFragment = "help";
046: }
047:
048: @Override
049: public int doPost(String[] parts, HttpServletRequest req,
050: HttpServletResponse res, Session session)
051: throws PortalHandlerException {
052: return doGet(parts, req, res, session);
053: }
054:
055: @Override
056: public int doGet(String[] parts, HttpServletRequest req,
057: HttpServletResponse res, Session session)
058: throws PortalHandlerException {
059: if ((parts.length >= 2) && (parts[1].equals("help"))) {
060: try {
061: doHelp(req, res, session, req.getContextPath()
062: + req.getServletPath()
063: + Web.makePath(parts, 1, 2), Web.makePath(
064: parts, 2, parts.length));
065: return END;
066: } catch (Exception ex) {
067: throw new PortalHandlerException(ex);
068: }
069: } else {
070: return NEXT;
071: }
072: }
073:
074: public void doHelp(HttpServletRequest req, HttpServletResponse res,
075: Session session, String toolContextPath, String toolPathInfo)
076: throws ToolException, IOException {
077: // permission check - none
078:
079: // get the detault skin
080: String skin = ServerConfigurationService
081: .getString("skin.default");
082:
083: // find the tool registered for this
084: ActiveTool tool = ActiveToolManager.getActiveTool("sakai.help");
085: if (tool == null) {
086: portal.doError(req, res, session, Portal.ERROR_WORKSITE);
087: return;
088: }
089:
090: // form a placement based on ... help TODO: is this enough?
091: // Note: the placement is transient, but will always have the same id
092: // and (null) context
093: org.sakaiproject.util.Placement placement = new org.sakaiproject.util.Placement(
094: "help", tool.getId(), tool, null, null, null);
095:
096: portal.forwardTool(tool, req, res, placement, skin,
097: toolContextPath, toolPathInfo);
098: }
099:
100: }
|