// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: StrutsPortlet.java
package org.apache.portals.bridges.struts;
import java.io.IOException;
import java.io.PrintWriter;
import javax.portlet.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.portals.bridges.common.ServletContextProvider;
import org.apache.portals.bridges.struts.config.RenderContextAttributes;
import org.apache.portals.bridges.struts.config.StrutsPortletConfig;
import org.apache.portals.bridges.struts.util.EmptyHttpServletResponseWrapper;
// Referenced classes of package org.apache.portals.bridges.struts:
// StrutsPortletErrorContext, PortletServletRequestWrapper
public class StrutsPortlet extends GenericPortlet
{
public StrutsPortlet()
{
defaultActionPage = null;
defaultCustomPage = null;
defaultEditPage = null;
defaultHelpPage = null;
defaultViewPage = null;
}
public void init(PortletConfig config)
throws PortletException
{
super.init(config);
String contextProviderClassName = getContextProviderClassNameParameter(config);
if(contextProviderClassName == null)
throw new PortletException((new StringBuilder()).append("Portlet ").append(config.getPortletName()).append(" is incorrectly configured. Init parameter ").append("ServletContextProvider").append(" not specified").toString());
if(contextProviderClassName != null)
try
{
Class clazz = Class.forName(contextProviderClassName);
if(clazz != null)
{
Object obj = clazz.newInstance();
if(org/apache/portals/bridges/common/ServletContextProvider.isInstance(obj))
servletContextProvider = (ServletContextProvider)obj;
else
throw new PortletException("class not found");
}
}
catch(Exception e)
{
if(e instanceof PortletException)
{
throw (PortletException)e;
} else
{
e.printStackTrace();
throw new PortletException("Cannot load", e);
}
}
if(servletContextProvider == null)
throw new PortletException((new StringBuilder()).append("Portlet ").append(config.getPortletName()).append(" is incorrectly configured. Invalid init parameter ").append("ServletContextProvider").append(" value ").append(contextProviderClassName).toString());
defaultActionPage = getActionPageParameter(config);
defaultCustomPage = getCustomPageParameter(config);
defaultEditPage = getEditPageParameter(config);
defaultViewPage = getViewPageParameter(config);
defaultHelpPage = getHelpPageParameter(config);
if(defaultViewPage == null)
throw new PortletException((new StringBuilder()).append("Portlet ").append(config.getPortletName()).append(" is incorrectly configured. No default View page is defined.").toString());
if(defaultActionPage == null)
defaultActionPage = defaultViewPage;
if(defaultCustomPage == null)
defaultCustomPage = defaultViewPage;
if(defaultHelpPage == null)
defaultHelpPage = defaultViewPage;
if(defaultEditPage == null)
defaultEditPage = defaultViewPage;
strutsPortletConfig = new StrutsPortletConfig();
String strutsPortletConfigLocation = getStrutsPortletConfigLocationParameter(config);
if(strutsPortletConfigLocation == null)
strutsPortletConfigLocation = "WEB-INF/struts-portlet-config.xml";
strutsPortletConfig.loadConfig(config.getPortletContext(), strutsPortletConfigLocation);
config.getPortletContext().setAttribute("org.apache.portals.bridges.struts.portlet_config", strutsPortletConfig);
}
protected String getContextProviderClassNameParameter(PortletConfig config)
{
return config.getInitParameter("ServletContextProvider");
}
protected ServletContextProvider getServletContextProvider()
{
return servletContextProvider;
}
protected ServletContext getServletContext(GenericPortlet portlet, PortletRequest request, PortletResponse response)
{
return getServletContextProvider().getServletContext(portlet);
}
protected HttpServletRequest getHttpServletRequest(GenericPortlet portlet, PortletRequest request, PortletResponse response)
{
return getServletContextProvider().getHttpServletRequest(portlet, request);
}
protected HttpServletResponse getHttpServletResponse(GenericPortlet portlet, PortletRequest request, PortletResponse response)
{
return getServletContextProvider().getHttpServletResponse(portlet, response);
}
protected String getActionPageParameter(PortletConfig config)
{
return config.getInitParameter("ActionPage");
}
protected String getCustomPageParameter(PortletConfig config)
{
return config.getInitParameter("CustomPage");
}
protected String getEditPageParameter(PortletConfig config)
{
return config.getInitParameter("EditPage");
}
protected String getViewPageParameter(PortletConfig config)
{
return config.getInitParameter("ViewPage");
}
protected String getHelpPageParameter(PortletConfig config)
{
return config.getInitParameter("HelpPage");
}
protected String getStrutsPortletConfigLocationParameter(PortletConfig config)
{
return config.getInitParameter("StrutsPortletConfigLocation");
}
public void doEdit(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
processRequest(request, response, defaultEditPage, "EDIT");
}
public void doHelp(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
processRequest(request, response, defaultHelpPage, "HELP");
}
public void doCustom(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
processRequest(request, response, defaultCustomPage, "CUSTOM");
}
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException
{
processRequest(request, response, defaultViewPage, "VIEW");
}
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException
{
processRequest(request, response, defaultActionPage, "ACTION");
}
protected void processRequest(PortletRequest request, PortletResponse response, String defaultPage, String requestType)
throws PortletException, IOException
{
ServletContext servletContext = getServletContext(this, request, response);
HttpServletRequest req = getHttpServletRequest(this, request, response);
HttpServletResponse res = getHttpServletResponse(this, request, response);
HttpSession session = req.getSession();
String portletName = getPortletConfig().getPortletName();
req.setAttribute("org.apache.portals.bridges.struts.portlet_name", portletName);
boolean actionRequest = request instanceof ActionRequest;
StrutsPortletErrorContext errorContext;
String keepRenderAttributes;
String path;
String pageURL;
RequestDispatcher rd;