}
} else {
throw new ProcessingException("buildProfile: Type unknown: " + type);
}
SessionContext context = this.getContext(true);
try {
this.getTransactionManager().startWritingTransaction(context);
String profileID = this.getProfileID(type, role, id, adminProfile);
Map theProfile = null;
// get the configuration
Map config = this.getConfiguration();
if (config == null) {
throw new ProcessingException("No configuration for portal found.");
}
// is the ID profile cached?
if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
theProfile = this.getCachedProfile(profileID, config);
}
if (theProfile == null) {
boolean doBase = false;
boolean doGlobal = false;
boolean doRole = false;
boolean doID = false;
String previousID;
if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
doID = true;
previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, adminProfile);
theProfile = this.getCachedProfile(previousID, config);
if (theProfile == null) {
doRole = true;
previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile);
theProfile = this.getCachedProfile(previousID, config);
if (theProfile == null) {
doGlobal = true;
previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
theProfile = this.getCachedProfile(previousID, config);
}
}
} else if (type.equals(PortalManager.BUILDTYPE_VALUE_ROLE) == true) {
theProfile = this.getCachedProfile(profileID, config);
if (theProfile == null) {
doRole = true;
previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile);
theProfile = this.getCachedProfile(previousID, config);
if (theProfile == null) {
doGlobal = true;
previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
theProfile = this.getCachedProfile(previousID, config);
}
}
} else if (type.equals(PortalManager.BUILDTYPE_VALUE_GLOBAL) == true) {
theProfile = this.getCachedProfile(profileID, config);
if (theProfile == null) {
doGlobal = true;
previousID = this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile);
theProfile = this.getCachedProfile(previousID, config);
}
} else { // basic profile
theProfile = this.getCachedProfile(profileID, config);
}
// build the profile
if (theProfile == null) {
theProfile = new HashMap(8,2);
doBase = true;
}
Element profileRoot;
DocumentFragment profile;
if (doBase == true) {
// build the base level
profile = this.buildBaseProfile(config, adminProfile);
profileRoot = (Element)profile.getFirstChild();
theProfile.put(PortalConstants.PROFILE_PROFILE, profile);
this.cacheProfile(this.getProfileID(PortalManager.BUILDTYPE_VALUE_BASIC, null, null, adminProfile), theProfile, config);
} else {
profile = (DocumentFragment)theProfile.get(PortalConstants.PROFILE_PROFILE);
profileRoot = (Element)profile.getFirstChild();
}
// load the global delta if type is global, role or user (but not basic!)
if (doGlobal == true) {
this.buildGlobalProfile(profileRoot, config, adminProfile);
this.cacheProfile(this.getProfileID(PortalManager.BUILDTYPE_VALUE_GLOBAL, null, null, adminProfile), theProfile, config);
}
// load the role delta if type is role or user
if (doRole == true) {
this.buildRoleProfile(profileRoot, config, role, adminProfile);
this.cacheProfile(this.getProfileID(PortalManager.BUILDTYPE_VALUE_ROLE, role, null, adminProfile), theProfile, config);
}
// load the user delta if type is user
if (doID == true) {
this.buildUserProfile(profileRoot, config, role, id, adminProfile);
}
// load the status profile when type is user
if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
this.buildUserStatusProfile(profileRoot, config, role, id, adminProfile);
}
if (type.equals(PortalManager.BUILDTYPE_VALUE_BASIC) == false) {
this.buildRunProfile(theProfile, context, profile);
theProfile.put(PortalConstants.PROFILE_PORTAL_LAYOUTS,
this.buildPortalLayouts(context, profile));
theProfile.put(PortalConstants.PROFILE_COPLET_LAYOUTS,
this.buildcopleyLayouts(context, profile));
this.buildTypeProfile(theProfile, context, profile);
}
// cache the profile, if user
if (doID == true) {
this.cacheProfile(profileID, theProfile, config);
}
} else {
// load the status profile when type is user
if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true) {
DocumentFragment profile = (DocumentFragment)theProfile.get(PortalConstants.PROFILE_PROFILE);
Element profileRoot = (Element)profile.getFirstChild();
this.buildUserStatusProfile(profileRoot, config, role, id, adminProfile);
}
}
// store the whole profile
this.storeProfile(profileID, theProfile);
// now put role and id into the context if type is ID
if (type.equals(PortalManager.BUILDTYPE_VALUE_ID) == true
&& adminProfile == false) {
context.setAttribute(PortalManager.ATTRIBUTE_PORTAL_ROLE, role);
context.setAttribute(PortalManager.ATTRIBUTE_PORTAL_ID, id);
}
} finally {
this.getTransactionManager().stopWritingTransaction(context);
}// end synchronized
} catch (javax.xml.transform.TransformerException local) {