/********************************************************************************** * $URL: https://source.sakaiproject.org/svn/tags/sakai_2-1-1/portal/charon/src/java/org/sakaiproject/portal/charon/CharonPortal.java $ * $Id: CharonPortal.java 4046 2005-11-21 13:20:38Z lance@indiana.edu $ ********************************************************************************** * * Copyright (c) 2005 The Regents of the University of Michigan, Trustees of Indiana University, * Board of Trustees of the Leland Stanford, Jr., University, and The MIT Corporation * * Licensed under the Educational Community License Version 1.0 (the "License"); * By obtaining, using and/or copying this Original Work, you agree that you have read, * understand, and will comply with the terms and conditions of the Educational Community License. * You may obtain a copy of the License at: * * http://cvs.sakaiproject.org/licenses/license_1_0.html * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * **********************************************************************************/ package org.sakaiproject.portal.charon; import java.io.IOException; import java.io.PrintWriter; import java.text.DateFormat; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.ResourceBundle; import java.util.Vector; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; 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.api.kernel.session.Session; import org.sakaiproject.api.kernel.session.ToolSession; import org.sakaiproject.api.kernel.session.cover.SessionManager; import org.sakaiproject.api.kernel.thread_local.cover.ThreadLocalManager; import org.sakaiproject.api.kernel.tool.ActiveTool; import org.sakaiproject.api.kernel.tool.Placement; import org.sakaiproject.api.kernel.tool.Tool; import org.sakaiproject.api.kernel.tool.ToolURL; import org.sakaiproject.api.kernel.tool.cover.ActiveToolManager; import org.sakaiproject.api.kernel.tool.cover.ToolManager; import org.sakaiproject.exception.IdUnusedException; import org.sakaiproject.exception.PermissionException; import org.sakaiproject.portal.charon.ToolURLManagerImpl; import org.sakaiproject.service.framework.config.cover.ServerConfigurationService; import org.sakaiproject.service.legacy.authzGroup.Role; import org.sakaiproject.service.legacy.entity.ResourceProperties; import org.sakaiproject.service.legacy.preference.Preferences; import org.sakaiproject.service.legacy.preference.cover.PreferencesService; import org.sakaiproject.service.legacy.security.cover.SecurityService; import org.sakaiproject.service.legacy.site.Site; import org.sakaiproject.service.legacy.site.SitePage; import org.sakaiproject.service.legacy.site.ToolConfiguration; import org.sakaiproject.service.legacy.site.cover.SiteService; import org.sakaiproject.util.java.StringUtil; import org.sakaiproject.util.web.Web; /** *
* Charon is the Sakai Site based portal. *
* * @author University of Michigan, Sakai Software Development Team * @version $Revision: 4046 $ */ public class CharonPortal extends HttpServlet { /** Our log (commons). */ private static Log M_log = LogFactory.getLog(CharonPortal.class); /** messages. */ private static ResourceBundle rb = ResourceBundle.getBundle("sitenav"); /** Session attribute root for storing a site's last page visited - just append the site id. */ protected static final String ATTR_SITE_PAGE = "sakai.portal.site."; /** ThreadLocal attribute set while we are processing an error. */ protected static final String ATTR_ERROR = "org.sakaiproject.portal.error"; /** Error response modes. */ protected static final int ERROR_SITE = 0; protected static final int ERROR_GALLERY = 1; protected static final int ERROR_WORKSITE = 2; /** Names of tool config/registration attributes that control the rendering of the tool's titlebar */ private static final String TOOLCONFIG_SHOW_RESET_BUTTON = "reset.button"; private static final String TOOLCONFIG_SHOW_HELP_BUTTON = "help.button"; private static final String TOOLCONFIG_HELP_DOCUMENT_ID = "help.id"; private static final String TOOLCONFIG_HELP_DOCUMENT_URL = "help.url"; /** * Shutdown the servlet. */ public void destroy() { M_log.info("destroy()"); super.destroy(); } protected void doError(HttpServletRequest req, HttpServletResponse res, Session session, int mode) throws IOException { if (ThreadLocalManager.get(ATTR_ERROR) == null) { ThreadLocalManager.set(ATTR_ERROR, ATTR_ERROR); // send to the error site switch (mode) { case ERROR_SITE: { doSite(req, res, session, "!error", null, req.getContextPath() + req.getServletPath()); break; } case ERROR_GALLERY: { doGallery(req, res, session, "!error", null, req.getContextPath() + req.getServletPath()); break; } case ERROR_WORKSITE: { doWorksite(req, res, session, "!error", null, req.getContextPath() + req.getServletPath()); break; } } return; } // error and we cannot use the error site... // form a context sensitive title String title = ServerConfigurationService.getString("ui.service") + " : Portal"; // start the response PrintWriter out = startResponse(res, title, null); // Show session information out.println("