String[] backendNames = root.listBackends();
for (int i=0; i<backendNames.length; i++)
{
try
{
BackendCfg backend = root.getBackend(backendNames[i]);
SortedSet<BaseDNDescriptor> baseDNs = new TreeSet<BaseDNDescriptor>();
for (DN dn : backend.getBaseDN())
{
BaseDNDescriptor baseDN =
new BaseDNDescriptor(BaseDNDescriptor.Type.NOT_REPLICATED, dn,
null, -1, -1, -1);
baseDNs.add(baseDN);
}
SortedSet<IndexDescriptor> indexes = new TreeSet<IndexDescriptor>();
SortedSet<VLVIndexDescriptor> vlvIndexes =
new TreeSet<VLVIndexDescriptor>();
BackendDescriptor.Type type;
if (backend instanceof LocalDBBackendCfg)
{
type = BackendDescriptor.Type.LOCAL_DB;
LocalDBBackendCfg db = (LocalDBBackendCfg)backend;
String[] indexNames = db.listLocalDBIndexes();
try
{
for (int j=0; j<indexNames.length; j++)
{
LocalDBIndexCfg index = db.getLocalDBIndex(indexNames[j]);
indexes.add(new IndexDescriptor(
index.getAttribute().getNameOrOID(), index.getAttribute(),
null, index.getIndexType(), index.getIndexEntryLimit()));
}
}
catch (OpenDsException oe)
{
ex.add(oe);
}
indexes.add(new IndexDescriptor("dn2id", null, null,
new TreeSet<IndexType>(), -1));
indexes.add(new IndexDescriptor("id2children", null, null,
new TreeSet<IndexType>(), -1));
indexes.add(new IndexDescriptor("id2subtree", null, null,
new TreeSet<IndexType>(), -1));
String[] vlvIndexNames = db.listLocalDBVLVIndexes();
try
{
for (int j=0; j<vlvIndexNames.length; j++)
{
LocalDBVLVIndexCfg index =
db.getLocalDBVLVIndex(vlvIndexNames[j]);
String s = index.getSortOrder();
List<VLVSortOrder> sortOrder = getVLVSortOrder(s);
vlvIndexes.add(new VLVIndexDescriptor(index.getName(), null,
index.getBaseDN(), index.getScope(), index.getFilter(),
sortOrder, index.getMaxBlockSize()));
}
}
catch (OpenDsException oe)
{
ex.add(oe);
}
}
else if (backend instanceof LDIFBackendCfg)
{
type = BackendDescriptor.Type.LDIF;
}
else if (backend instanceof MemoryBackendCfg)
{
type = BackendDescriptor.Type.MEMORY;
}
else if (backend instanceof BackupBackendCfg)
{
type = BackendDescriptor.Type.BACKUP;
}
else if (backend instanceof MonitorBackendCfg)
{
type = BackendDescriptor.Type.MONITOR;
}
else if (backend instanceof TaskBackendCfg)
{
type = BackendDescriptor.Type.TASK;
}
else
{
type = BackendDescriptor.Type.OTHER;
}
BackendDescriptor desc = new BackendDescriptor(
backend.getBackendId(), baseDNs, indexes, vlvIndexes, -1,
backend.isEnabled(), type);
for (AbstractIndexDescriptor index: indexes)
{
index.setBackend(desc);
}
for (AbstractIndexDescriptor index: vlvIndexes)
{
index.setBackend(desc);
}
bs.add(desc);
}
catch (OpenDsException oe)
{
ex.add(oe);
}
}
boolean isReplicationSecure = false;
try
{
CryptoManagerCfg cryptoManager = root.getCryptoManager();
isReplicationSecure = cryptoManager.isSSLEncryption();
}
catch (OpenDsException oe)
{
ex.add(oe);
}
replicationPort = -1;
ReplicationSynchronizationProviderCfg sync = null;
try
{
sync = (ReplicationSynchronizationProviderCfg)
root.getSynchronizationProvider("Multimaster Synchronization");
}
catch (OpenDsException oe)
{
// Ignore this one
}
if (sync != null)
{
try
{
if (sync.isEnabled() && sync.hasReplicationServer())
{
ReplicationServerCfg replicationServer =
sync.getReplicationServer();
if (replicationServer != null)
{
replicationPort = replicationServer.getReplicationPort();
ConnectionHandlerDescriptor.Protocol protocol =
isReplicationSecure ?
ConnectionHandlerDescriptor.Protocol.REPLICATION_SECURE :
ConnectionHandlerDescriptor.Protocol.REPLICATION;
Set<CustomSearchResult> emptySet = Collections.emptySet();
ConnectionHandlerDescriptor connHandler =
new ConnectionHandlerDescriptor(
new HashSet<InetAddress>(),
replicationPort,
protocol,
ConnectionHandlerDescriptor.State.ENABLED,
"Multimaster Synchronization",
emptySet);
ls.add(connHandler);
}
}
String[] domains = sync.listReplicationDomains();
if (domains != null)
{
for (int i=0; i<domains.length; i++)
{
ReplicationDomainCfg domain =
sync.getReplicationDomain(domains[i]);
DN dn = domain.getBaseDN();
for (BackendDescriptor backend : bs)
{
for (BaseDNDescriptor baseDN : backend.getBaseDns())
{
if (baseDN.getDn().equals(dn))
{
baseDN.setType(BaseDNDescriptor.Type.REPLICATED);
baseDN.setReplicaID(domain.getServerId());