venice-main-classic/src/com/silverwrist/venice/ui/servlet/CommunityDispatchServlet.java
2002-01-07 02:05:37 +00:00

69 lines
2.6 KiB
Java

/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (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.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui.servlet;
import org.apache.log4j.*;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.helpers.*;
public class CommunityDispatchServlet extends BaseServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(CommunityDispatchServlet.class);
/*--------------------------------------------------------------------------------
* Implementations from class BaseServlet
*--------------------------------------------------------------------------------
*/
public Object process(RequestInput req)
{
// get the community alias name from the request path info
String alias = req.getPathInfo().substring(1);
try
{ // get the community's context from the alias name
CommunityContext comm = req.getUser().getCommunityContext(alias);
// get the default servlet from the community context
String def_servlet = req.getDefaultServletAddress(comm);
if (logger.isDebugEnabled())
logger.debug("CommunityDispatchServlet bouncing to: " + def_servlet);
if (def_servlet==null)
return new ErrorBox("Internal Error","Unable to get community default servlet.","top.js.vs");
// now go there
return new Redirect(def_servlet,LinkTypes.ABSOLUTE);
} // end try
catch (DataException de)
{ // set up to display an ErrorBox
return new ErrorBox("Database Error","Database error finding community: " + de.getMessage(),"top.js.vs");
} // end catch
} // end process
} // end class CommunityDispatchServlet