/**
* @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(Object)
*/
public Layout getPortalLayout(String key) {
PortalService service = null;
LayoutFactory factory = null;
try {
service = (PortalService) this.manager.lookup(PortalService.ROLE);
factory = (LayoutFactory) this.manager.lookup(LayoutFactory.ROLE);
if ( null == key ) {
Layout l = (Layout) service.getTemporaryAttribute("DEFAULT_LAYOUT");
if ( null != l) {
return l;
}
}
String portalPrefix = "/"+service.getPortalName();
// TODO Change to KeyManager usage
UserHandler handler = RequestState.getState().getHandler();
HashMap map = new HashMap();
map.put("portalname", service.getPortalName());
map.put("user", handler.getUserId());
map.put("role", handler.getContext().getContextInfo().get("role"));
// load coplet base data
map.put("profile", "copletbasedata");
map.put("objectmap", null);
Object[] result = this.getProfile(map, portalPrefix+"/CopletBaseData", service);
if (result[0] == null) {
throw new SourceNotFoundException("Could not find coplet base data profile.");
}
CopletBaseDataManager copletBaseDataManager = (CopletBaseDataManager)result[0];
boolean lastLoaded = ((Boolean)result[1]).booleanValue();
// load coplet data
map.put("profile", "copletdata");
map.put("objectmap", copletBaseDataManager.getCopletBaseData());
result = this.getDeltaProfile(map, portalPrefix+"/CopletData", service);
if (result[0] == null) {
throw new SourceNotFoundException("Could not find coplet data profile.");
}
CopletDataManager copletDataManager = (CopletDataManager)result[0];
boolean loaded = ((Boolean)result[1]).booleanValue();
if (lastLoaded && !loaded) {
copletDataManager.update(copletBaseDataManager);
}
lastLoaded = loaded;
// load coplet instance data
map.put("profile", "copletinstancedata");
map.put("objectmap", copletDataManager.getCopletData());
result = this.getOrCreateProfile(map, portalPrefix+"/CopletInstanceData", service);
CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)result[0];
loaded = ((Boolean)result[1]).booleanValue();
if (lastLoaded && !loaded) {
copletInstanceDataManager.update(copletDataManager);
}
lastLoaded = loaded;
// load layout
map.put("profile", "layout");
map.put("objectmap", ((CopletInstanceDataManager)result[0]).getCopletInstanceData());
result = this.getOrCreateProfile(map, portalPrefix+"/Layout", service);
Layout layout = (Layout)result[0];
loaded = ((Boolean)result[1]).booleanValue();
if (lastLoaded && !loaded) {
resolveParents(layout, null, copletInstanceDataManager);
} else {
resolveParents(layout, null, null);
}
factory.prepareLayout( layout );
return layout;
} catch (Exception ce) {
// TODO
throw new CascadingRuntimeException("Arg", ce);