} else {
configStream =
config.getServletContext().getResourceAsStream("/WEB-INF/registry.xml");
}
RegistryContext registryContext = RegistryContext.getBaseInstance(configStream,
new RegistryContext.RegURLSupplier() {
public String getURL() {
return config.getServletContext().getRealPath("/WEB-INF");
}
});
embeddedRegistryService = registryContext.getEmbeddedRegistryService();
// create a system registry and put it in the context
UserRegistry systemRegistry = embeddedRegistryService.getConfigSystemRegistry();
// add configured handers to the jdbc registry
// note: no need to do this here. this is done inside the registry context
//Iterator<HandlerConfiguration> handlers =
// registryContext.getHandlerConfigurations().iterator();
//while (handlers.hasNext()) {
// HandlerConfiguration handlerConfiguration = handlers.next();
// registryContext.getHandlerManager().addHandler(0,
// handlerConfiguration.getFilter(), handlerConfiguration.getHandler());
//}
// create system resources
NodeGroupLock.lock(NodeGroupLock.INITIALIZE_LOCK);
if (log.isTraceEnabled()) {
log.trace("Creating system collections used in WSO2 Registry server.");
}
if (!systemRegistry.resourceExists("/system")) {
try {
boolean inTransaction = Transaction.isStarted();
if (!inTransaction) {
systemRegistry.beginTransaction();
}
Collection systemCollection = systemRegistry.newCollection();
String systemDesc = "This collection is used to store system data of the " +
"WSO2 Registry server. User nor the admins of the registry are not expected " +
"to edit any content of this collection. Changing content of this collection " +
"may result in unexpected behaviors.";
systemCollection.setDescription(systemDesc);
systemRegistry.put("/system", systemCollection);
Collection advancedQueryCollection = systemRegistry.newCollection();
String advaceDesc = "This collection is used to store auto generated queries " +
"to support various combinations of advanced search criteria. " +
"This is initialy empty and gets filled as advanced search is " +
"executed from the web UI.";
advancedQueryCollection.setDescription(advaceDesc);
systemRegistry.put("/system/queries/advanced", advancedQueryCollection);
if (!inTransaction) {
systemRegistry.commitTransaction();
}
} catch (Exception e) {
String msg = "Unable to setup system collections used by the Carbon server.";
log.error(msg, e);
systemRegistry.rollbackTransaction();
throw new RegistryException(e.getMessage(), e);
}
}
try {
AuthorizationManager ac = systemRegistry.getUserRealm().getAuthorizationManager();
RealmConfiguration realmConfig;
realmConfig = registryContext.getRealmService().getBootstrapRealmConfiguration();
String systemUserName = CarbonConstants.REGISTRY_SYSTEM_USERNAME;
ac.clearResourceAuthorizations("/system");