Configuration sitemapConfig = null;
try {
this.configurationFile.refresh();
p = (Parser)startupManager.lookup(Parser.ROLE);
SAXConfigurationHandler b = new SAXConfigurationHandler();
InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/cocoon.roles").openStream();
InputSource is = new InputSource(inputStream);
is.setSystemId(this.configurationFile.getSystemId());
p.setContentHandler(b);
p.parse(is);
roleConfig = b.getConfiguration();
} catch (Exception e) {
getLogger().error("Could not configure Cocoon environment", e);
throw new ConfigurationException("Error trying to load configurations", e);
} finally {
if (p != null) startupManager.release(p);
}
DefaultRoleManager drm = new DefaultRoleManager();
drm.setLogger(getLogger());
drm.configure(roleConfig);
roleConfig = null;
try {
this.configurationFile.refresh();
p = (Parser)startupManager.lookup(Parser.ROLE);
SAXConfigurationHandler b = new SAXConfigurationHandler();
InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/sitemap/sitemap.roles").openStream();
InputSource is = new InputSource(inputStream);
is.setSystemId(this.configurationFile.getSystemId());
p.setContentHandler(b);
p.parse(is);
sitemapConfig = b.getConfiguration();
} catch (Exception e) {
getLogger().error("Could not configure Cocoon environment", e);
throw new ConfigurationException("Error trying to load configurations", e);
} finally {
if (p != null) startupManager.release(p);
}
DefaultRoleManager sitemapRoleManager = new DefaultRoleManager();
sitemapRoleManager.setLogger(getLogger());
sitemapRoleManager.configure(sitemapConfig);
try {
p = (Parser)startupManager.lookup(Parser.ROLE);
SAXConfigurationHandler b = new SAXConfigurationHandler();
InputSource is = this.configurationFile.getInputSource();
p.setContentHandler(b);
p.parse(is);
this.configuration = b.getConfiguration();
} catch (Exception e) {
getLogger().error("Could not configure Cocoon environment", e);
throw new ConfigurationException("Error trying to load configurations",e);
} finally {
if (p != null) startupManager.release(p);
}
Configuration conf = this.configuration;
AbstractSitemap.setRoleManager(sitemapRoleManager, conf);
AbstractSitemap.setLogKitManager(this.logKitManager);
getLogger().debug("Root configuration: " + conf.getName());
if (! "cocoon".equals(conf.getName())) {
throw new ConfigurationException("Invalid configuration file\n" + conf.toString());
}
getLogger().debug("Configuration version: " + conf.getAttribute("version"));
if (Constants.CONF_VERSION.equals(conf.getAttribute("version")) == false) {
throw new ConfigurationException("Invalid configuration schema version. Must be '" + Constants.CONF_VERSION + "'.");
}
String userRoles = conf.getAttribute("user-roles", "");
if ("".equals(userRoles) == false) {
try {
p = (Parser)startupManager.lookup(Parser.ROLE);
SAXConfigurationHandler b = new SAXConfigurationHandler();
org.apache.cocoon.environment.Context context =
(org.apache.cocoon.environment.Context) this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
URL url = context.getResource(userRoles);
InputSource is = new InputSource(new BufferedInputStream(url.openStream()));
is.setSystemId(this.configurationFile.getSystemId());
p.setContentHandler(b);
p.parse(is);
roleConfig = b.getConfiguration();
} catch (Exception e) {
getLogger().error("Could not configure Cocoon environment", e);
throw new ConfigurationException("Error trying to load configurations", e);
} finally {
if (p != null) startupManager.release(p);