* @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(String, String)
*/
public Layout getPortalLayout(String layoutKey, String layoutID)
{
PortalService service = null;
ProfileLS adapter = null;
try
{
service = (PortalService) this.manager.lookup(PortalService.ROLE);
if (layoutKey == null)
{
Layout l = getEntryLayout();
if (null != l)
{
return l;
}
layoutKey = getDefaultLayoutKey();
}
String serviceKey = LAYOUTKEY_PREFIX + layoutKey;
Object[] objects = (Object[]) service.getAttribute(serviceKey);
// check if the layout is already cached and still valid
int valid = SourceValidity.INVALID;
SourceValidity sourceValidity = null;
if (objects != null)
{
sourceValidity = (SourceValidity) objects[1];
valid = sourceValidity.isValid();
Layout layout = null;
if (valid == SourceValidity.VALID)
layout = (Layout) ((Map) objects[0]).get(layoutID);
if (layout != null)
return layout;
}
CopletInstanceDataManager copletInstanceDataManager = getCopletInstanceDataManager(service);
Map parameters = new HashMap();
parameters.put("profiletype", "layout");
parameters.put("objectmap", copletInstanceDataManager.getCopletInstanceData());
Map map = new SequencedHashMap();
map.put("base", this.profilesPath);
map.put("portalname", service.getPortalName());
map.put("profile", "layout");
map.put("groupKey", layoutKey);
adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
SourceValidity newValidity = adapter.getValidity(map, parameters);
if (valid == SourceValidity.UNKNOWN)
{
if (sourceValidity.isValid(newValidity) == SourceValidity.VALID)
{
return (Layout) ((Map) objects[0]).get(layoutID);
}
}
// get Layout specified in the map
Layout layout = (Layout) adapter.loadProfile(map, parameters);
Map layouts = new HashMap();
layouts.put(null, layout); //save root with null as key
cacheLayouts(layouts, layout);