Set<TopologyCacheException> exceptions =
new HashSet<TopologyCacheException>();
Set<ServerDescriptor> servers = cache.getServers();
for (ServerDescriptor server : servers)
{
TopologyCacheException e = server.getLastException();
if (e != null)
{
exceptions.add(e);
}
}
/* Check the exceptions and see if we throw them or not. */
boolean notGlobalAdministratorError = false;
for (TopologyCacheException e : exceptions)
{
if (notGlobalAdministratorError)
{
break;
}
switch (e.getType())
{
case NOT_GLOBAL_ADMINISTRATOR:
notGlobalAdministratorError = true;
boolean connected = false;
String adminUid = uData.getAdminUid();
String adminPwd = uData.getAdminPwd();
boolean errorDisplayed = false;
while (!connected)
{
if ((!triedWithUserProvidedAdmin) && (adminPwd == null))
{
adminUid = getValue(argParser.getAdministratorUID(),
argParser.getDefaultAdministratorUID());
adminPwd = argParser.getBindPasswordAdmin();
triedWithUserProvidedAdmin = true;
}
if (adminPwd == null)
{
if (!errorDisplayed)
{
println();
println(
INFO_NOT_GLOBAL_ADMINISTRATOR_PROVIDED.get());
errorDisplayed = true;
}
adminUid = askForAdministratorUID(
argParser.getDefaultAdministratorUID(), LOG);
println();
adminPwd = askForAdministratorPwd(LOG);
println();
}
try
{
ctx[0].close();
}
catch (Throwable t)
{
}
try
{
ctx[0] = createAdministrativeContext(host, port, isSSL,
isStartTLS, ADSContext.getAdministratorDN(adminUid),
adminPwd, getConnectTimeout(), getTrustManager());
adsContext = new ADSContext(ctx[0]);
cache = new TopologyCache(adsContext, getTrustManager(),
getConnectTimeout());
cache.getFilter().setSearchMonitoringInformation(false);
cache.getFilter().setSearchBaseDNInformation(false);
cache.setPreferredConnections(
PreferredConnection.getPreferredConnections(ctx[0]));
connected = true;
}
catch (Throwable t)
{
println();
println(
ERR_ERROR_CONNECTING_TO_SERVER_PROMPT_AGAIN.get(
getServerRepresentation(host, port), t.getMessage()));
LOG.log(Level.WARNING, "Complete error stack:", t);
println();
}
}
uData.setAdminUid(adminUid);
uData.setAdminPwd(adminPwd);
if (uData instanceof EnableReplicationUserData)
{
EnableReplicationUserData enableData =
(EnableReplicationUserData)uData;
if (isFirstOrSourceServer)
{
enableData.setBindDn1(
ADSContext.getAdministratorDN(adminUid));
enableData.setPwd1(adminPwd);
}
else
{
enableData.setBindDn2(
ADSContext.getAdministratorDN(adminUid));
enableData.setPwd2(adminPwd);
}
}
reloadTopology = true;
break;
case GENERIC_CREATING_CONNECTION:
if ((e.getCause() != null) &&
Utils.isCertificateException(e.getCause()))
{
reloadTopology = true;
cancelled = !ci.promptForCertificateConfirmation(e.getCause(),
e.getTrustManager(), e.getLdapUrl(), true, LOG);
}
else
{
exceptionMsgs.add(Utils.getMessage(e));
}