* @see org.apache.portals.applications.webcontent.portlet.WebContentPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException
{
// portal request context
RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
// default page view rendering
String viewPage = (String)request.getAttribute(PARAM_VIEW_PAGE);
if (viewPage != null)
{
super.doView(request, response);
return;
}
// get source web content URL, parameters, and method to view
String sourceURL = null;
Map sourceParams = null;
boolean sourcePostMethod = false;
WebContentHistoryPage webContentPage = (WebContentHistoryPage)PortletMessaging.receive(request, getClass().getName());
if (webContentPage != null)
{
// view rewritten action URL page
sourceURL = webContentPage.getUrl();
sourceParams = webContentPage.getParams();
sourcePostMethod = webContentPage.isPost();
}
else
{
// load and validate preferences, (base url and portal base path
// should both end in a "/" path separator to ensure that relative
// urls in the content resolve predictably)
String baseURL = request.getPreferences().getValue("SRC", null);
String portalBasePath = request.getPreferences().getValue("PORTALPATH", null);
if ((baseURL == null) || (portalBasePath == null))
{
throw new PortletException("Required SRC and PORTALPATH preferences not set");
}
if (!baseURL.endsWith("/"))
{
baseURL += "/";
}
if (!portalBasePath.startsWith("/"))
{
portalBasePath = "/"+portalBasePath;
}
if (!portalBasePath.endsWith("/"))
{
portalBasePath += "/";
}
// view content page based on portal request URL
String portalRequestPath = rc.getPath();
if (!portalRequestPath.startsWith(portalBasePath))
{
throw new PortletException("Unable to map portal request path: "+portalRequestPath+" onto portal base path: "+portalBasePath);
}
sourceURL = baseURL+portalRequestPath.substring(portalBasePath.length());
}
// get web content
byte[] content = null;
try
{
// initialize and lock stateful rewriter
String basePortalPath = rc.getPortalURL().getPageBasePath();
initializeRewriter(DynamicWebContentRewriter.class);
((DynamicWebContentRewriter)getRewriter()).setBasePortalPath(basePortalPath);
// get and rewrite web content
if (log.isDebugEnabled())
{
log.debug("Portal request: "+rc.getPath()+", Web content: "+sourceURL);
}
try
{
content = doWebContent(sourceURL, sourceParams, sourcePostMethod, request, response);
}