this.getLogger().debug("BEGIN getConfiguration");
}
Map result = null;
String appName = (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_APPLICATION_NAME);
String handlerName = (String)this.request.getAttribute(org.apache.cocoon.sunshine.sunrise.Constants.REQUEST_ATTRIBUTE_HANDLER_NAME);
Session session = this.getSunShineComponent().getSession(false);
if (session != null && appName != null && handlerName != null) {
synchronized (session) {
result = (Map)session.getAttribute(Constants.ATTRIBUTE_CONFIGURATION + handlerName + ':' + appName);
if (result == null) {
try {
Configuration config;
Configuration conf = this.getSunRise().getModuleConfiguration(Constants.SUNRISE_MODULE_NAME);
if (conf == null) {
throw new ProcessingException("sunSpot: Configuration for application '" + appName + "' not found.");
}
result = new HashMap(10, 2);
// auth-redirect (optional)
config = conf.getChild("auth-redirect", false);
if (config != null) {
result.put(Constants.CONF_AUTH_REDIRECT, config.getValue());
}
// portal-uri (required)
config = conf.getChild("portal-uri", false);
if (config == null) {
throw new ProcessingException("sunSpot: portal-uri required for application '"+appName+"'");
}
result.put(Constants.CONF_PORTAL_URI, config.getValue());
// profile-cache (optional)
config = conf.getChild("profile-cache", false);
if (config != null && config.getValueAsBoolean() == true) {
result.put(Constants.CONF_PROFILE_CACHE, appName);
}
// parallel sunlets
config = conf.getChild("process-sunlets-parallel", false);
if (config != null) {
result.put(Constants.CONF_PARALLEL_SUNLETS, new Boolean(config.getValueAsBoolean(false)));
} else {
result.put(Constants.CONF_PARALLEL_SUNLETS, new Boolean(false));
}
// timeout
config = conf.getChild("default-sunlet-timeout", false);
if (config != null) {
result.put(Constants.CONF_SUNLET_TIMEOUT, new Long(config.getValueAsLong(600000)));
} else {
result.put(Constants.CONF_SUNLET_TIMEOUT, new Long(600000));
}
// and now the profile
config = conf.getChild("profile", false);
if (config == null) throw new ProcessingException("sunSpot: profile configuration required for application '" + appName + "'");
Configuration child;
// build resource (optional)
child = config.getChild("buildprofile", false);
if (child != null) {
result.put(Constants.CONF_BUILD_RESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// base resource, type is optional
child = config.getChild("layout-base", false);
if (child == null) {
throw new ProcessingException("sunSpot: layout-base required for application '" + appName + "'");
}
result.put(Constants.CONF_LAYOUTBASE_RESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
child = config.getChild("sunlet-base", false);
if (child == null) {
throw new ProcessingException("sunSpot: sunlet-base required for application '" + appName + "'");
}
result.put(Constants.CONF_SUNLETBASE_RESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
child = config.getChild("type-base", false);
if (child != null) {
result.put(Constants.CONF_TYPEBASE_RESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// sunlet base save (is optional)
child = config.getChild("sunlet-base-save", false);
if (child != null) {
result.put(Constants.CONF_SUNLETBASE_SAVE_RESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// global delta (load required)
child = config.getChild("global-delta-load", false);
if (child == null) {
throw new ProcessingException("sunSpot: global-delta-load required for application '" + appName + "'");
}
result.put(Constants.CONF_GLOBALDELTA_LOADRESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
child = config.getChild("global-delta-save", false);
if (child != null) {
result.put(Constants.CONF_GLOBALDELTA_SAVERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
child = config.getChild("global-type-delta", false);
if (child != null) {
result.put(Constants.CONF_GLOBALDELTA_TYPERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// role delta (optional)
child = config.getChild("role-delta-load", false);
if (child != null) {
result.put(Constants.CONF_ROLEDELTA_LOADRESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
child = config.getChild("role-delta-save", false);
if (child != null) {
result.put(Constants.CONF_ROLEDELTA_SAVERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
child = config.getChild("role-type-delta", false);
if (child != null) {
result.put(Constants.CONF_ROLEDELTA_TYPERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// User delta
child = config.getChild("user-delta-load", false);
if (child != null) {
result.put(Constants.CONF_USERDELTA_LOADRESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
child = config.getChild("user-delta-save", false);
if (child != null) {
result.put(Constants.CONF_USERDELTA_SAVERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
child = config.getChild("user-type-delta", false);
if (child != null) {
result.put(Constants.CONF_USERDELTA_TYPERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// Personal information
child = config.getChild("user-status-load", false);
if (child != null) {
result.put(Constants.CONF_STATUS_LOADRESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
child = config.getChild("user-status-save", false);
if (child != null) {
result.put(Constants.CONF_STATUS_SAVERESOURCE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// Admin Type profil
child = config.getChild("admin-type-base", false);
if (child != null) {
result.put(Constants.CONF_ADMIN_TYPE_BASE, new Resource(this.resolver,
child.getAttribute("uri")));
}
// store the config in the session
session.setAttribute(Constants.ATTRIBUTE_CONFIGURATION + handlerName + ':' + appName, result);
} catch (ConfigurationException conf) {
throw new ProcessingException("ConfigurationException: " + conf, conf);
}
}
}