/**********************************************************************************
 * $URL$
 * $Id$
 ***********************************************************************************
 *
 * Copyright (c) 2003, 2004 The Sakai Foundation.
 * 
 * Licensed under the Educational Community License, Version 1.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at
 * 
 *      http://www.opensource.org/licenses/ecl1.php
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 *
 **********************************************************************************/

package org.sakaiproject.tool.help;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.sakaiproject.jsf.util.JsfTool;
import org.sakaiproject.util.Web;

/**
 * HelpJsfTool extends JsfTool to support placement in the help frameset. 
 * 
 * @author <a href="mailto:jlannan.iupui.edu">Jarrod Lannan</a>
 * @version $Id$
 * 
 * 
 */
public class HelpJsfTool extends JsfTool
{

  /** Our log (commons). */
  private static Log M_log = LogFactory.getLog(HelpJsfTool.class);

  private static final String TOC_PATH = "/TOCDisplay/main";
  private static final String SEARCH_PATH = "/search/main";
  private static final String HELP_PATH = "/html";

  private static final String TOC_ATTRIBUTE = "tocURL";
  private static final String SEARCH_ATTRIBUTE = "searchURL";
  private static final String HELP_ATTRIBUTE = "helpURL";

  /**
   * @see org.sakaiproject.jsf.util.JsfTool#dispatch(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  protected void dispatch(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException
  {
    req.setAttribute(TOC_ATTRIBUTE, Web.returnUrl(req, TOC_PATH));
    req.setAttribute(SEARCH_ATTRIBUTE, Web.returnUrl(req, SEARCH_PATH));
    req.setAttribute(HELP_ATTRIBUTE, Web.returnUrl(req, HELP_PATH));
    super.dispatch(req, res);
  }
}



@@ -1189,16 +1189,84 @@
 actory;%0A
+import org.sakaiproject.component.cover.ServerConfigurationService;%0A
 import o
@@ -1299,16 +1299,16 @@
 sfTool;%0A
-
 import o
@@ -1999,17 +1999,264 @@
 lpURL%22;%0A
+  %0A  /** To determine if an external webapp handles help and if so, the base url */%0A  private static final String USE_EXTERNAL_WEBAPP = %22help.extern.webapp%22;%0A  private static final String EXTERNAL_WEBAPP_URL_BASE = %22help.extern.webapp.urlbase%22;%0A  
 %0A
-
   /**%0A  
@@ -2513,12 +2513,460 @@
 ion%0A
-
   %7B%0A
+%09    // if magic switch turned on, go to external webapp%0A%09    if (%22true%22.equals(ServerConfigurationService.getString(USE_EXTERNAL_WEBAPP))) %7B%0A%09       String docId = req.getParameter(%22help%22);%0A%09       %0A%09       String extUrl = ServerConfigurationService.getString(EXTERNAL_WEBAPP_URL_BASE);%0A%09       %0A%09       if (docId != null && ! %22%22.equals(%22docId%22)) %7B%0A%09    %09   extUrl += docId;%0A%09       %7D%0A%09    %09%0A%09       res.sendRedirect(extUrl);%0A%09%09   return;%0A%09    %7D%0A%0A
     

Allow redirection to external Help webapp.