{
BackendCfgClient 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 LocalDBBackendCfgClient)
{
type = BackendDescriptor.Type.LOCAL_DB;
LocalDBBackendCfgClient db = (LocalDBBackendCfgClient)backend;
String[] indexNames = db.listLocalDBIndexes();
try
{
for (int j=0; j<indexNames.length; j++)
{
LocalDBIndexCfgClient 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++)
{
LocalDBVLVIndexCfgClient 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 LDIFBackendCfgClient)
{
type = BackendDescriptor.Type.LDIF;
}
else if (backend instanceof MemoryBackendCfgClient)
{
type = BackendDescriptor.Type.MEMORY;
}
else if (backend instanceof BackupBackendCfgClient)
{
type = BackendDescriptor.Type.BACKUP;
}
else if (backend instanceof MonitorBackendCfgClient)
{
type = BackendDescriptor.Type.MONITOR;
}
else if (backend instanceof TaskBackendCfgClient)
{
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);
}
for (BaseDNDescriptor baseDN : baseDNs)
{
baseDN.setBackend(desc);
}
bs.add(desc);
}
catch (OpenDsException oe)
{
ex.add(oe);
}
}
boolean isReplicationSecure = false;
try
{
CryptoManagerCfgClient cryptoManager = root.getCryptoManager();
isReplicationSecure = cryptoManager.isSSLEncryption();
}
catch (OpenDsException oe)
{
ex.add(oe);
}
replicationPort = -1;
ReplicationSynchronizationProviderCfgClient sync = null;
try
{
sync = (ReplicationSynchronizationProviderCfgClient)
root.getSynchronizationProvider("Multimaster Synchronization");
}
catch (OpenDsException oe)
{
// Ignore this one
}
if (sync != null)
{
try
{
if (sync.isEnabled() && sync.hasReplicationServer())
{
ReplicationServerCfgClient 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++)
{
ReplicationDomainCfgClient 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());
}
}
}
}
}