You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by at...@apache.org on 2006/11/07 21:15:10 UTC
svn commit: r472231 -
/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/HeaderAggregatorImpl.java
Author: ate
Date: Tue Nov 7 12:15:10 2006
New Revision: 472231
URL: http://svn.apache.org/viewvc?view=rev&rev=472231
Log:
Fix several potential exceptions when trying to access non-available/existing portlets
BTW: I think the current implementation of access the real instance of a portlet is way to heavy...
Will try to come up with a simpler and more lightweight solution.
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/HeaderAggregatorImpl.java
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/HeaderAggregatorImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/HeaderAggregatorImpl.java?view=diff&rev=472231&r1=472230&r2=472231
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/HeaderAggregatorImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/aggregator/impl/HeaderAggregatorImpl.java Tue Nov 7 12:15:10 2006
@@ -38,6 +38,7 @@
import org.apache.jetspeed.headerresource.HeaderResource;
import org.apache.jetspeed.headerresource.HeaderResourceFactory;
import org.apache.jetspeed.headerresource.HeaderResourceLib;
+import org.apache.jetspeed.om.common.portlet.PortletApplication;
import org.apache.jetspeed.om.page.ContentFragment;
import org.apache.jetspeed.om.page.ContentPage;
import org.apache.jetspeed.portlet.PortletHeaderRequest;
@@ -869,25 +870,27 @@
{
try
{
- if ( fragment.getType().equals( ContentFragment.LAYOUT ) )
+ if ( !fragment.getType().equals( ContentFragment.LAYOUT ) )
{
- return false;
- }
-
- PortletWindow portletWindow = getPortletWindowAccessor().getPortletWindow( fragment );
- PortletDefinition pd = portletWindow.getPortletEntity().getPortletDefinition();
- String portletApplicationContextPath = pd.getPortletApplicationDefinition().getWebApplicationDefinition().getContextRoot();
- Portlet portlet = getPortletFactory().getPortletInstance( context.getConfig().getServletContext().getContext( portletApplicationContextPath ), pd ).getRealPortlet();
- if ( portlet instanceof SupportsHeaderPhase )
- {
- log.debug( "renderHeaderFragment: " + pd.getName() + " supports header phase" );
-
- HeaderResource hr = getHeaderResourceFactory().getHeaderResource( context, this.baseUrlAccess, isDesktop(), getHeaderConfiguration() );
- PortletHeaderRequest headerRequest = new PortletHeaderRequestImpl( context, portletWindow, portletApplicationContextPath );
- PortletHeaderResponse headerResponse = new PortletHeaderResponseImpl( context, hr, isDesktop(), getHeaderConfiguration(), getHeaderResourceRegistry() );
- ((SupportsHeaderPhase)portlet).doHeader( headerRequest, headerResponse );
- return true;
+ PortletWindow portletWindow = getPortletWindowAccessor().getPortletWindow( fragment );
+ PortletDefinition pd = portletWindow.getPortletEntity().getPortletDefinition();
+ if ( pd != null && getPortletFactory().isPortletApplicationRegistered((PortletApplication)pd.getPortletApplicationDefinition() ) )
+ {
+ String portletApplicationContextPath = pd.getPortletApplicationDefinition().getWebApplicationDefinition().getContextRoot();
+ Portlet portlet = getPortletFactory().getPortletInstance( context.getConfig().getServletContext().getContext( portletApplicationContextPath ), pd ).getRealPortlet();
+ if ( portlet != null && portlet instanceof SupportsHeaderPhase )
+ {
+ log.debug( "renderHeaderFragment: " + pd.getName() + " supports header phase" );
+
+ HeaderResource hr = getHeaderResourceFactory().getHeaderResource( context, this.baseUrlAccess, isDesktop(), getHeaderConfiguration() );
+ PortletHeaderRequest headerRequest = new PortletHeaderRequestImpl( context, portletWindow, portletApplicationContextPath );
+ PortletHeaderResponse headerResponse = new PortletHeaderResponseImpl( context, hr, isDesktop(), getHeaderConfiguration(), getHeaderResourceRegistry() );
+ ((SupportsHeaderPhase)portlet).doHeader( headerRequest, headerResponse );
+ return true;
+ }
+ }
}
+ return false;
}
catch ( Exception e )
{
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org