01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/help/tags/sakai_2-4-1/help-tool/src/java/org/sakaiproject/tool/help/HelpJsfTool.java $
03: * $Id: HelpJsfTool.java 20315 2007-01-12 20:21:59Z josrodri@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2003, 2004 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.tool.help;
21:
22: import java.io.IOException;
23:
24: import javax.servlet.ServletException;
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30: import org.sakaiproject.component.cover.ServerConfigurationService;
31: import org.sakaiproject.jsf.util.JsfTool;
32: import org.sakaiproject.util.Web;
33:
34: /**
35: * HelpJsfTool extends JsfTool to support placement in the help frameset.
36: *
37: * @author <a href="mailto:jlannan.iupui.edu">Jarrod Lannan</a>
38: * @version $Id: HelpJsfTool.java 20315 2007-01-12 20:21:59Z josrodri@iupui.edu $
39: *
40: *
41: */
42: public class HelpJsfTool extends JsfTool {
43:
44: /** Our log (commons). */
45: private static Log M_log = LogFactory.getLog(HelpJsfTool.class);
46:
47: private static final String TOC_PATH = "/TOCDisplay/main";
48: private static final String SEARCH_PATH = "/search/main";
49: private static final String HELP_PATH = "/html";
50:
51: private static final String TOC_ATTRIBUTE = "tocURL";
52: private static final String SEARCH_ATTRIBUTE = "searchURL";
53: private static final String HELP_ATTRIBUTE = "helpURL";
54:
55: /** To determine if an external webapp handles help and if so, the base url */
56: private static final String EXTERNAL_WEBAPP_URL_BASE = "help.redirect.external.webapp";
57: private static final String EXTERNAL_WEBAPP_URL = ServerConfigurationService
58: .getString(EXTERNAL_WEBAPP_URL_BASE, "sakai");
59:
60: /**
61: * @see org.sakaiproject.jsf.util.JsfTool#dispatch(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
62: */
63: protected void dispatch(HttpServletRequest req,
64: HttpServletResponse res) throws ServletException,
65: IOException {
66: // if magic switch turned on, go to external webapp
67: if (!"sakai".equals(EXTERNAL_WEBAPP_URL)) {
68: String docId = req.getParameter("help");
69:
70: String extUrl = EXTERNAL_WEBAPP_URL;
71:
72: if (docId != null && !"".equals("docId")) {
73: extUrl += docId;
74: }
75:
76: res.sendRedirect(extUrl);
77: return;
78: }
79:
80: req.setAttribute(TOC_ATTRIBUTE, Web.returnUrl(req, TOC_PATH));
81: req.setAttribute(SEARCH_ATTRIBUTE, Web.returnUrl(req,
82: SEARCH_PATH));
83: req.setAttribute(HELP_ATTRIBUTE, Web.returnUrl(req, HELP_PATH));
84: super.dispatch(req, res);
85: }
86: }
|