if ( null == page )
{
throw new JetspeedException( "Failed to find PSML Pin ContentPageAggregator.build" );
}
ContentFragment root = page.getRootContentFragment();
if ( root == null )
{
throw new JetspeedException( "No root ContentFragment found in ContentPage" );
}
// add named-resources and named-resources-added maps as request attributes
Map dynamicConfigDefault = getHeaderDynamicConfigurationDefault();
Map namedResourcesDefault = getHeaderNamedResourcesDefault();
Map namedResourcesAddedFragmentsDefault = getHeaderNamedResourcesAddedFragmentsDefault();
/*if ( log.isDebugEnabled() && namedResourcesDefault != null )
{
Iterator namedResourcesDefaultIter = namedResourcesDefault.entrySet().iterator();
while ( namedResourcesDefaultIter.hasNext() )
{
Map.Entry rsrcEntry = (Map.Entry)namedResourcesDefaultIter.next();
Object rsrcVal = rsrcEntry.getValue();
log.debug( rsrcEntry.getKey().toString() + ": " + EOL + ( rsrcVal != null ? rsrcVal.toString() : "null" ) );
}
}*/
if ( dynamicConfigDefault != null || namedResourcesDefault != null || namedResourcesAddedFragmentsDefault != null )
{
Map existingNamedResources = (Map)context.getAttribute( PortalReservedParameters.HEADER_NAMED_RESOURCE_ATTRIBUTE );
if ( existingNamedResources == null )
{
if ( dynamicConfigDefault == null )
{
context.setAttribute( PortalReservedParameters.HEADER_CONFIGURATION_ATTRIBUTE, new HashMap() );
}
else
{
HashMap dynamicConfig = new HashMap();
Iterator hConfigEntryIter = dynamicConfigDefault.entrySet().iterator();
while ( hConfigEntryIter.hasNext() )
{
Map.Entry hConfigEntry = (Map.Entry)hConfigEntryIter.next();
Object hConfigKey = hConfigEntry.getKey();
Object hConfigVal = hConfigEntry.getValue();
if ( hConfigVal instanceof Map )
{
dynamicConfig.put( hConfigKey, new HashMap( (Map)hConfigVal ) );
}
else if ( hConfigVal instanceof List )
{
dynamicConfig.put( hConfigKey, new ArrayList( (List)hConfigVal ) );
}
else
{
dynamicConfig.put( hConfigKey, hConfigVal );
}
}
context.setAttribute( PortalReservedParameters.HEADER_CONFIGURATION_ATTRIBUTE, dynamicConfig );
}
if ( namedResourcesDefault != null )
{
context.setAttribute( PortalReservedParameters.HEADER_NAMED_RESOURCE_ATTRIBUTE, new HashMap( namedResourcesDefault ) );
}
if ( namedResourcesAddedFragmentsDefault != null )
{
context.setAttribute( PortalReservedParameters.HEADER_NAMED_RESOURCE_ADDED_FRAGMENTS_ATTRIBUTE, new HashMap( namedResourcesAddedFragmentsDefault ) );
}
}
}
if ( getHeaderResourceRegistry() != null )
{
context.setAttribute( PortalReservedParameters.HEADER_NAMED_RESOURCE_REGISTRY_ATTRIBUTE, getHeaderResourceRegistry() );
}
// handle maximized state
boolean atLeastOneHasHeaderPhase = false;
NavigationalState nav = context.getPortalURL().getNavigationalState();
PortletWindow window = nav.getMaximizedWindow();
if ( null != window )
{
ContentFragment maxedContentFragment = page.getContentFragmentById( window.getId().toString() );
if ( maxedContentFragment != null )
{
atLeastOneHasHeaderPhase = renderHeaderFragment( context, maxedContentFragment );
}
}