return sb.toString();
}
// Obtains a registry instance to work with, based on the configuration
private Registry getRegistry(RequestContext requestContext) throws Exception {
RegistryContext baseContext = RegistryContext.getBaseInstance();
if (!isHandlerRegistered && baseContext != null) {
try {
Registry systemRegistry = new UserRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME,
CurrentSession.getTenantId(), requestContext.getRegistry(),
baseContext.getRealmService(), baseContext.getRegistryRoot());
if (subPath != null) {
RegistryUtils.addMountEntry(systemRegistry, RegistryContext.getBaseInstance(),
mountPoint, id, subPath, author);
} else {
RegistryUtils.addMountEntry(systemRegistry, RegistryContext.getBaseInstance(),
mountPoint, id, true, author);
}
isHandlerRegistered = true;
} catch (RegistryException e) {
log.error("Unable to add mount entry into Registry", e);
}
}
if (remote) {
if (registryProvider == null && registryType != null) {
BundleContext bundleContext = RegistryCoreServiceComponent.getBundleContext();
if (bundleContext != null) {
ServiceTracker tracker =
new ServiceTracker(bundleContext, RegistryProvider.class.getName(),
null);
tracker.open();
ServiceReference[] references = tracker.getServiceReferences();
if (references != null) {
for (ServiceReference reference : references) {
if (registryType.equals(reference.getProperty("type"))) {
registryProvider = (RegistryProvider) tracker.getService(reference);
break;
}
}
}
tracker.close();
}
}
if (registryProvider != null) {
return registryProvider.getRegistry(this.conURL, this.userName, this.password);
}
RegistryUtils.setTrustStoreSystemProperties();
return new RemoteRegistry(this.conURL, this.userName, this.password);
}
if (registryService == null) {
RegistryContext context = RegistryContext.getCloneContext();
context.setRegistryRoot(registryRoot);
context.setReadOnly(readOnly);
context.setCacheEnabled(cacheEnabled);
context.selectDBConfig(dbConfig);
registryService = context.getEmbeddedRegistryService();
}
return registryService.getUserRegistry(CurrentSession.getUser(),
CurrentSession.getCallerTenantId());
}