Settings settings = SettingsHelper.getSettings(this.context);
Configuration roles = null;
try {
p = (SAXParser) startupManager.lookup(SAXParser.ROLE);
SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, this.getLogger());
URL url = ClassUtils.getResource("org/apache/cocoon/cocoon.roles");
InputSource is = new InputSource(url.openStream());
is.setSystemId(url.toString());
p.parse(is, b);
roles = b.getConfiguration();
} catch (Exception e) {
throw new ConfigurationException("Error trying to load configurations", e);
} finally {
if (p != null) startupManager.release((Component) p);
}
DefaultRoleManager drm = new DefaultRoleManager();
ContainerUtil.enableLogging(drm, this.rootLogger.getChildLogger("roles"));
ContainerUtil.configure(drm, roles);
roles = null;
try {
this.configurationFile.refresh();
p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, this.getLogger());
InputSource is = SourceUtil.getInputSource(this.configurationFile);
p.parse(is, b);
this.configuration = b.getConfiguration();
} catch (Exception e) {
throw new ConfigurationException("Error trying to load configurations",e);
} finally {
if (p != null) startupManager.release((Component)p);
}
Configuration conf = this.configuration;
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("Root configuration: " + conf.getName());
}
if (!"cocoon".equals(conf.getName())) {
throw new ConfigurationException("Invalid configuration file\n" + conf.toString());
}
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("Configuration version: " + conf.getAttribute("version"));
}
if (!Constants.CONF_VERSION.equals(conf.getAttribute("version"))) {
throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
}
String userRoles = conf.getAttribute("user-roles", "");
if (!"".equals(userRoles)) {
try {
p = (SAXParser)startupManager.lookup(SAXParser.ROLE);
SAXConfigurationHandler b = new PropertyAwareSAXConfigurationHandler(settings, this.getLogger());
org.apache.cocoon.environment.Context context =
(org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
URL url = context.getResource(userRoles);
if (url == null) {
throw new ConfigurationException("User-roles configuration '"+userRoles+"' cannot be found.");
}
InputSource is = new InputSource(new BufferedInputStream(url.openStream()));
is.setSystemId(url.toString());
p.parse(is, b);
roles = b.getConfiguration();
} catch (Exception e) {
throw new ConfigurationException("Error trying to load user-roles configuration", e);
} finally {
startupManager.release((Component)p);
}