/* (non-Javadoc)
* @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(java.lang.String, java.lang.String)
*/
public Layout getPortalLayout(String layoutKey, String layoutID) {
PortalService service = null;
ServiceSelector adapterSelector = null;
try {
service = (PortalService) this.manager.lookup(PortalService.ROLE);
LayoutFactory factory = service.getComponentManager().getLayoutFactory();
CopletFactory copletFactory = service.getComponentManager().getCopletFactory();
adapterSelector = (ServiceSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
if ( null == layoutKey ) {
layoutKey = this.getDefaultLayoutKey();
}
// FIXME actually this is a hack for full screen
Layout l = (Layout) service.getTemporaryAttribute("DEFAULT_LAYOUT:" + layoutKey);
if ( null != l) {
return l;
}
final String layoutAttributeKey = "Layout:" + layoutKey;
final String layoutObjectsAttributeKey = "Layout-Map:" + layoutKey;
Layout layout = (Layout)service.getAttribute(layoutAttributeKey);
if (layout == null) {
layout = this.loadProfile(layoutKey, service, copletFactory, factory, adapterSelector);
}
if ( layoutID != null ) {
// now search for a layout
Map layoutMap = (Map)service.getAttribute(layoutObjectsAttributeKey);
if ( layoutMap == null ) {
layoutMap = new HashMap();
this.cacheLayouts(layoutMap, layout);
service.setAttribute(layoutObjectsAttributeKey, layoutMap);
}
if ( layoutMap != null) {
return (Layout) layoutMap.get( layoutID );
}
}