| | |
| | | import org.opends.admin.ads.ADSContext.ServerProperty; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.OpendsCertificateException; |
| | | import org.opends.admin.ads.util.PreferredConnection; |
| | | import org.opends.admin.ads.util.ServerLoader; |
| | | import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; |
| | |
| | | import org.opends.quicksetup.ApplicationException; |
| | | import org.opends.quicksetup.Constants; |
| | | import org.opends.quicksetup.Installation; |
| | | import org.opends.quicksetup.ReturnCode; |
| | | import org.opends.quicksetup.event.ProgressUpdateEvent; |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.installer.Installer; |
| | |
| | | import org.opends.quicksetup.installer.PeerNotFoundException; |
| | | import org.opends.quicksetup.installer.offline.OfflineInstaller; |
| | | import org.opends.quicksetup.util.PlainTextProgressMessageFormatter; |
| | | import org.opends.quicksetup.util.Utils; |
| | | |
| | | import static org.opends.quicksetup.util.Utils.createLdapsContext; |
| | | import static org.opends.quicksetup.util.Utils.createStartTLSContext; |
| | | import static org.opends.quicksetup.util.Utils.areDnsEqual; |
| | | import static org.opends.quicksetup.util.Utils.isLocalHost; |
| | | import static org.opends.quicksetup.util.Utils.isCertificateException; |
| | | import static org.opends.quicksetup.util.Utils.getMessage; |
| | | import static org.opends.quicksetup.util.Utils.getMessageFromCollection; |
| | | import static org.opends.quicksetup.util.Utils.getServerClock; |
| | | |
| | | import org.opends.server.admin.*; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor; |
| | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.FileBasedArgument; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | import com.forgerock.opendj.cli.CommandBuilder; |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.MenuBuilder; |
| | | import com.forgerock.opendj.cli.TabSeparatedTablePrinter; |
| | | import com.forgerock.opendj.cli.TableBuilder; |
| | | import com.forgerock.opendj.cli.TablePrinter; |
| | | import com.forgerock.opendj.cli.TextTablePrinter; |
| | | import com.forgerock.opendj.cli.MenuResult; |
| | | import com.forgerock.opendj.cli.ValidationCallback; |
| | | |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.LDAPConnectionConsoleInteraction; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | | import org.opends.server.util.table.TabSeparatedTablePrinter; |
| | | import org.opends.server.util.table.TableBuilder; |
| | | import org.opends.server.util.table.TablePrinter; |
| | | import org.opends.server.util.table.TextTablePrinter; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_BAD_INTEGER; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_ADMINISTRATOR_PWD_PROMPT; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_ADMINISTRATOR_UID_PROMPT; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_PROMPT_SINGLE_DEFAULT; |
| | | import static com.forgerock.opendj.cli.Utils.CONFIRMATION_MAX_TRIES; |
| | | import static com.forgerock.opendj.cli.Utils.getCurrentOperationDateMessage; |
| | | import static com.forgerock.opendj.cli.Utils.getMessageForException; |
| | | import static com.forgerock.opendj.cli.Utils.SHELL_COMMENT_SEPARATOR; |
| | | import static org.forgerock.util.Utils.joinAsString; |
| | | |
| | | import org.opends.server.util.cli.PointAdder; |
| | | import org.opends.server.util.cli.MenuResult; |
| | | import org.opends.server.util.cli.LDAPConnectionConsoleInteraction; |
| | | |
| | | import javax.naming.NameAlreadyBoundException; |
| | | import javax.naming.NameNotFoundException; |
| | | import javax.naming.NamingEnumeration; |
| | | import javax.naming.NamingException; |
| | | import javax.naming.NoPermissionException; |
| | | import javax.naming.directory.*; |
| | | import javax.naming.ldap.InitialLdapContext; |
| | | import javax.net.ssl.KeyManager; |
| | | import javax.net.ssl.SSLException; |
| | | import javax.net.ssl.SSLHandshakeException; |
| | | import javax.net.ssl.TrustManager; |
| | | |
| | | import java.io.*; |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.admin.ads.ServerDescriptor.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | import static org.opends.messages.DSConfigMessages.ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT; |
| | | import static org.opends.messages.DSConfigMessages.ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED; |
| | | import static org.opends.messages.DSConfigMessages.ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT; |
| | | import static org.opends.messages.QuickSetupMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.messages.UtilityMessages. |
| | |
| | | */ |
| | | public ReplicationCliMain(PrintStream out, PrintStream err, InputStream in) |
| | | { |
| | | super(in, out, err); |
| | | super(out, err); |
| | | } |
| | | |
| | | /** |
| | |
| | | return returnValue.getReturnCode(); |
| | | } |
| | | |
| | | /** |
| | | * Prompts the user to give the Global Administrator UID. |
| | | * |
| | | * @param defaultValue |
| | | * the default value that will be proposed in the prompt message. |
| | | * @param logger |
| | | * the Logger to be used to log the error message. |
| | | * @return the Global Administrator UID as provided by the user. |
| | | */ |
| | | protected String askForAdministratorUID(String defaultValue, |
| | | LocalizedLogger logger) |
| | | { |
| | | String s = defaultValue; |
| | | try |
| | | { |
| | | s = readInput(INFO_ADMINISTRATOR_UID_PROMPT.get(), defaultValue); |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | | } |
| | | return s; |
| | | } |
| | | |
| | | /** |
| | | * Prompts the user to give the Global Administrator password. |
| | | * |
| | | * @param logger |
| | | * the Logger to be used to log the error message. |
| | | * @return the Global Administrator password as provided by the user. |
| | | */ |
| | | protected String askForAdministratorPwd(LocalizedLogger logger) |
| | | { |
| | | String pwd = null; |
| | | try |
| | | { |
| | | readPassword(INFO_ADMINISTRATOR_PWD_PROMPT.get()); |
| | | } |
| | | catch (ClientException ex) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ex, ex)); |
| | | } |
| | | return pwd; |
| | | } |
| | | |
| | | /** |
| | | * Commodity method used to repeatidly ask the user to provide an integer |
| | | * value. |
| | | * |
| | | * @param prompt |
| | | * the prompt message. |
| | | * @param defaultValue |
| | | * the default value to be proposed to the user. |
| | | * @param logger |
| | | * the logger where the errors will be written. |
| | | * @return the value provided by the user. |
| | | */ |
| | | protected int askInteger(LocalizableMessage prompt, int defaultValue, |
| | | LocalizedLogger logger) |
| | | { |
| | | int newInt = -1; |
| | | while (newInt == -1) |
| | | { |
| | | try |
| | | { |
| | | newInt = readInteger(prompt, defaultValue); |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | newInt = -1; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | | } |
| | | } |
| | | return newInt; |
| | | } |
| | | |
| | | /** |
| | | * Interactively retrieves an integer value from the console. |
| | | * |
| | | * @param prompt |
| | | * The message prompt. |
| | | * @param defaultValue |
| | | * The default value. |
| | | * @return Returns the value. |
| | | * @throws ClientException |
| | | * If the value could not be retrieved for some reason. |
| | | */ |
| | | public final int readInteger( |
| | | LocalizableMessage prompt, final int defaultValue) throws ClientException |
| | | { |
| | | ValidationCallback<Integer> callback = new ValidationCallback<Integer>() |
| | | { |
| | | @Override |
| | | public Integer validate(ConsoleApplication app, String input) |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | | { |
| | | return defaultValue; |
| | | } |
| | | else |
| | | { |
| | | try |
| | | { |
| | | int i = Integer.parseInt(ninput); |
| | | if (i < 1) |
| | | { |
| | | throw new NumberFormatException(); |
| | | } |
| | | return i; |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | // Try again... |
| | | app.println(); |
| | | app.println(ERR_BAD_INTEGER.get(ninput)); |
| | | app.println(); |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | }; |
| | | |
| | | if (defaultValue != -1) |
| | | { |
| | | prompt = INFO_PROMPT_SINGLE_DEFAULT.get(prompt, defaultValue); |
| | | } |
| | | |
| | | return readValidatedInput(prompt, callback, CONFIRMATION_MAX_TRIES); |
| | | } |
| | | |
| | | |
| | | private boolean isFirstCallFromScript() |
| | | { |
| | | return FIRST_SCRIPT_CALL.equals(System.getProperty(SCRIPT_CALL_STATUS)); |
| | |
| | | { |
| | | String separator = formatter.getLineBreak().toString() + |
| | | formatter.getTab().toString(); |
| | | printlnProgress(); |
| | | println(); |
| | | LocalizableMessage msg = formatter.getFormattedProgress( |
| | | INFO_PROGRESS_PURGE_HISTORICAL.get(separator, |
| | | joinAsString(separator, uData.getBaseDNs()))); |
| | | printProgress(msg); |
| | | printlnProgress(); |
| | | print(msg); |
| | | println(); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns an InitialLdapContext using the provided parameters. We try to |
| | | * guarantee that the connection is able to read the configuration. |
| | | * |
| | | * @param host |
| | | * the host name. |
| | | * @param port |
| | | * the port to connect. |
| | | * @param useSSL |
| | | * whether to use SSL or not. |
| | | * @param useStartTLS |
| | | * whether to use StartTLS or not. |
| | | * @param bindDn |
| | | * the bind dn to be used. |
| | | * @param pwd |
| | | * the password. |
| | | * @param connectTimeout |
| | | * the timeout in milliseconds to connect to the server. |
| | | * @param trustManager |
| | | * the trust manager. |
| | | * @return an InitialLdapContext connected. |
| | | * @throws NamingException |
| | | * if there was an error establishing the connection. |
| | | */ |
| | | private InitialLdapContext createAdministrativeContext(String host, |
| | | int port, boolean useSSL, boolean useStartTLS, String bindDn, String pwd, |
| | | int connectTimeout, ApplicationTrustManager trustManager) |
| | | throws NamingException |
| | | { |
| | | InitialLdapContext ctx; |
| | | String ldapUrl = ConnectionUtils.getLDAPUrl(host, port, useSSL); |
| | | if (useSSL) |
| | | { |
| | | ctx = |
| | | createLdapsContext(ldapUrl, bindDn, pwd, connectTimeout, null, |
| | | trustManager); |
| | | } |
| | | else if (useStartTLS) |
| | | { |
| | | ctx = |
| | | createStartTLSContext(ldapUrl, bindDn, pwd, connectTimeout, |
| | | null, trustManager, null); |
| | | } |
| | | else |
| | | { |
| | | ctx = ConnectionUtils.createLdapContext(ldapUrl, bindDn, pwd, connectTimeout, null); |
| | | } |
| | | if (!ConnectionUtils.connectedAsAdministrativeUser(ctx)) |
| | | { |
| | | throw new NoPermissionException(ERR_NOT_ADMINISTRATIVE_USER.get() |
| | | .toString()); |
| | | } |
| | | return ctx; |
| | | } |
| | | |
| | | /** |
| | | * Creates an Initial LDAP Context interacting with the user if the |
| | | * application is interactive. |
| | | * |
| | | * @param ci |
| | | * the LDAPConnectionConsoleInteraction object that is assumed to |
| | | * have been already run. |
| | | * @return the initial LDAP context or <CODE>null</CODE> if the user did not |
| | | * accept to trust the certificates. |
| | | * @throws ClientException |
| | | * if there was an error establishing the connection. |
| | | */ |
| | | protected InitialLdapContext createInitialLdapContextInteracting( |
| | | LDAPConnectionConsoleInteraction ci) throws ClientException |
| | | { |
| | | return createInitialLdapContextInteracting(ci, isInteractive() |
| | | && ci.isTrustStoreInMemory()); |
| | | } |
| | | |
| | | private OpendsCertificateException getCertificateRootException(Throwable t) |
| | | { |
| | | OpendsCertificateException oce = null; |
| | | while (t != null && oce == null) |
| | | { |
| | | t = t.getCause(); |
| | | if (t instanceof OpendsCertificateException) |
| | | { |
| | | oce = (OpendsCertificateException) t; |
| | | } |
| | | } |
| | | return oce; |
| | | } |
| | | |
| | | /** |
| | | * Creates an Initial LDAP Context interacting with the user if the |
| | | * application is interactive. |
| | | * |
| | | * @param ci |
| | | * the LDAPConnectionConsoleInteraction object that is assumed to |
| | | * have been already run. |
| | | * @param promptForCertificate |
| | | * whether we should prompt for the certificate or not. |
| | | * @return the initial LDAP context or <CODE>null</CODE> if the user did not |
| | | * accept to trust the certificates. |
| | | * @throws ClientException |
| | | * if there was an error establishing the connection. |
| | | */ |
| | | protected InitialLdapContext createInitialLdapContextInteracting( |
| | | LDAPConnectionConsoleInteraction ci, boolean promptForCertificate) |
| | | throws ClientException |
| | | { |
| | | // Interact with the user though the console to get |
| | | // LDAP connection information |
| | | String hostName = ConnectionUtils.getHostNameForLdapUrl(ci.getHostName()); |
| | | Integer portNumber = ci.getPortNumber(); |
| | | String bindDN = ci.getBindDN(); |
| | | String bindPassword = ci.getBindPassword(); |
| | | TrustManager trustManager = ci.getTrustManager(); |
| | | KeyManager keyManager = ci.getKeyManager(); |
| | | |
| | | InitialLdapContext ctx; |
| | | |
| | | if (ci.useSSL()) |
| | | { |
| | | String ldapsUrl = "ldaps://" + hostName + ":" + portNumber; |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | ctx = |
| | | ConnectionUtils.createLdapsContext(ldapsUrl, bindDN, |
| | | bindPassword, ci.getConnectTimeout(), null, trustManager, |
| | | keyManager); |
| | | ctx.reconnect(null); |
| | | break; |
| | | } |
| | | catch (NamingException e) |
| | | { |
| | | if (promptForCertificate) |
| | | { |
| | | OpendsCertificateException oce = getCertificateRootException(e); |
| | | if (oce != null) |
| | | { |
| | | String authType = null; |
| | | if (trustManager instanceof ApplicationTrustManager) |
| | | { |
| | | ApplicationTrustManager appTrustManager = |
| | | (ApplicationTrustManager) trustManager; |
| | | authType = appTrustManager.getLastRefusedAuthType(); |
| | | } |
| | | if (ci.checkServerCertificate(oce.getChain(), authType, hostName)) |
| | | { |
| | | // If the certificate is trusted, update the trust manager. |
| | | trustManager = ci.getTrustManager(); |
| | | |
| | | // Try to connect again. |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | // Assume user canceled. |
| | | return null; |
| | | } |
| | | } |
| | | } |
| | | if (e.getCause() != null) |
| | | { |
| | | if (!isInteractive() && !ci.isTrustAll()) |
| | | { |
| | | if (getCertificateRootException(e) != null |
| | | || (e.getCause() instanceof SSLHandshakeException)) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | if (e.getCause() instanceof SSLException) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | String hostPort = |
| | | ServerDescriptor.getServerRepresentation(hostName, portNumber); |
| | | LocalizableMessage message = getMessageForException(e, hostPort); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else if (ci.useStartTLS()) |
| | | { |
| | | String ldapUrl = "ldap://" + hostName + ":" + portNumber; |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | ctx = |
| | | ConnectionUtils.createStartTLSContext(ldapUrl, bindDN, |
| | | bindPassword, ConnectionUtils.getDefaultLDAPTimeout(), null, |
| | | trustManager, keyManager, null); |
| | | ctx.reconnect(null); |
| | | break; |
| | | } |
| | | catch (NamingException e) |
| | | { |
| | | if (promptForCertificate) |
| | | { |
| | | OpendsCertificateException oce = getCertificateRootException(e); |
| | | if (oce != null) |
| | | { |
| | | String authType = null; |
| | | if (trustManager instanceof ApplicationTrustManager) |
| | | { |
| | | ApplicationTrustManager appTrustManager = |
| | | (ApplicationTrustManager) trustManager; |
| | | authType = appTrustManager.getLastRefusedAuthType(); |
| | | } |
| | | |
| | | if (ci.checkServerCertificate(oce.getChain(), authType, hostName)) |
| | | { |
| | | // If the certificate is trusted, update the trust manager. |
| | | trustManager = ci.getTrustManager(); |
| | | |
| | | // Try to connect again. |
| | | continue; |
| | | } |
| | | else |
| | | { |
| | | // Assume user cancelled. |
| | | return null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | String ldapUrl = "ldap://" + hostName + ":" + portNumber; |
| | | while (true) |
| | | { |
| | | try |
| | | { |
| | | ctx = |
| | | ConnectionUtils.createLdapContext(ldapUrl, bindDN, bindPassword, |
| | | ConnectionUtils.getDefaultLDAPTimeout(), null); |
| | | ctx.reconnect(null); |
| | | break; |
| | | } |
| | | catch (NamingException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | | } |
| | | return ctx; |
| | | } |
| | | |
| | | private ReplicationCliReturnCode purgeHistoricalRemotely( |
| | | PurgeHistoricalUserData uData) |
| | | { |
| | |
| | | |
| | | private void printSuccessMessage(PurgeHistoricalUserData uData, String taskID) |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | if (!uData.isOnline()) |
| | | { |
| | | printProgress( |
| | | print( |
| | | INFO_PROGRESS_PURGE_HISTORICAL_FINISHED_PROCEDURE.get()); |
| | | } |
| | | else if (uData.getTaskSchedule().isStartNow()) |
| | | { |
| | | printProgress(INFO_TASK_TOOL_TASK_SUCESSFULL.get( |
| | | print(INFO_TASK_TOOL_TASK_SUCESSFULL.get( |
| | | INFO_PURGE_HISTORICAL_TASK_NAME.get(), |
| | | taskID)); |
| | | } |
| | | else if (uData.getTaskSchedule().getStartDate() != null) |
| | | { |
| | | printProgress(INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get( |
| | | print(INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get( |
| | | INFO_PURGE_HISTORICAL_TASK_NAME.get(), |
| | | taskID, |
| | | StaticUtils.formatDateTimeString( |
| | |
| | | } |
| | | else |
| | | { |
| | | printProgress(INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get( |
| | | print(INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get( |
| | | INFO_PURGE_HISTORICAL_TASK_NAME.get(), |
| | | taskID)); |
| | | } |
| | | |
| | | printlnProgress(); |
| | | println(); |
| | | } |
| | | |
| | | /** |
| | |
| | | boolean found = false; |
| | | for (String dn1 : availableSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(dn, dn1)) |
| | | if (areDnsEqual(dn, dn1)) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | boolean notReplicated = false; |
| | | for (String s : notReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s, dn)) |
| | | if (areDnsEqual(s, dn)) |
| | | { |
| | | notReplicated = true; |
| | | break; |
| | |
| | | boolean noSchemaOrAds = false; |
| | | for (String s: availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | noSchemaOrAds = true; |
| | | } |
| | |
| | | println(ERR_NO_SUFFIXES_SELECTED_TO_PURGE_HISTORICAL.get()); |
| | | for (String dn : availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(dn, |
| | | if (!areDnsEqual(dn, |
| | | ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | !areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | promptForConnection = |
| | | !askConfirmation( |
| | | INFO_REPLICATION_PURGE_HISTORICAL_LOCAL_PROMPT.get(), |
| | |
| | | /* Prompt for maximum duration */ |
| | | if (!argParser.maximumDurationArg.isPresent()) |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | maximumDuration = askInteger( |
| | | INFO_REPLICATION_PURGE_HISTORICAL_MAXIMUM_DURATION_PROMPT.get(), |
| | | argParser.getDefaultMaximumDuration(), logger); |
| | |
| | | argParser.getDefaultReplicationPort1(), logger); |
| | | println(); |
| | | } |
| | | if (!argParser.skipReplicationPortCheck() && Utils.isLocalHost(host1)) |
| | | if (!argParser.skipReplicationPortCheck() && isLocalHost(host1)) |
| | | { |
| | | if (!SetupUtils.canUseAsPort(replicationPort1)) |
| | | { |
| | |
| | | uData.setSecureReplication1(secureReplication1); |
| | | uData.setConfigureReplicationServer1(configureReplicationServer1); |
| | | uData.setConfigureReplicationDomain1(configureReplicationDomain1); |
| | | firstServerCommandBuilder = new CommandBuilder(null); |
| | | firstServerCommandBuilder = new CommandBuilder(null, null); |
| | | if (mustPrintCommandBuilder()) |
| | | { |
| | | firstServerCommandBuilder.append(ci.getCommandBuilder()); |
| | |
| | | println(); |
| | | } |
| | | if (!argParser.skipReplicationPortCheck() && |
| | | Utils.isLocalHost(host2)) |
| | | isLocalHost(host2)) |
| | | { |
| | | if (!SetupUtils.canUseAsPort(replicationPort2)) |
| | | { |
| | |
| | | String adminPwdConfirm = null; |
| | | while (adminPwdConfirm == null) |
| | | { |
| | | adminPwdConfirm = |
| | | readPassword(INFO_ADMINISTRATOR_PWD_CONFIRM_PROMPT.get(), logger); |
| | | try |
| | | { |
| | | adminPwdConfirm = |
| | | String |
| | | .valueOf(readPassword(INFO_ADMINISTRATOR_PWD_CONFIRM_PROMPT |
| | | .get())); |
| | | } |
| | | catch (ClientException ex) |
| | | { |
| | | logger.warn(LocalizableMessage |
| | | .raw("Error reading input: " + ex, ex)); |
| | | } |
| | | println(); |
| | | } |
| | | if (!adminPwd.equals(adminPwdConfirm)) |
| | |
| | | boolean disableSchema = false; |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | | if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | { |
| | | disableADS = true; |
| | | } |
| | | else if (Utils.areDnsEqual(Constants.SCHEMA_DN, dn)) |
| | | else if (areDnsEqual(Constants.SCHEMA_DN, dn)) |
| | | { |
| | | disableSchema = true; |
| | | } |
| | |
| | | boolean initializeADS = false; |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | | if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | { |
| | | initializeADS = true; |
| | | } |
| | |
| | | uData.setAdminPwd(adminPwd); |
| | | } |
| | | |
| | | firstServerCommandBuilder = new CommandBuilder(null); |
| | | firstServerCommandBuilder = new CommandBuilder(null, null); |
| | | if (mustPrintCommandBuilder()) |
| | | { |
| | | firstServerCommandBuilder.append(ci.getCommandBuilder()); |
| | |
| | | boolean initializeADS = false; |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | | if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | { |
| | | initializeADS = true; |
| | | break; |
| | |
| | | break; |
| | | case GENERIC_CREATING_CONNECTION: |
| | | if ((e.getCause() != null) && |
| | | Utils.isCertificateException(e.getCause())) |
| | | isCertificateException(e.getCause())) |
| | | { |
| | | reloadTopology = true; |
| | | cancelled = !ci.promptForCertificateConfirmation(e.getCause(), |
| | |
| | | } |
| | | else |
| | | { |
| | | exceptionMsgs.add(Utils.getMessage(e)); |
| | | exceptionMsgs.add(getMessage(e)); |
| | | } |
| | | break; |
| | | default: |
| | | exceptionMsgs.add(Utils.getMessage(e)); |
| | | exceptionMsgs.add(getMessage(e)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | println( |
| | | ERR_REPLICATION_STATUS_READING_REGISTERED_SERVERS.get( |
| | | Utils.getMessageFromCollection(exceptionMsgs, |
| | | getMessageFromCollection(exceptionMsgs, |
| | | Constants.LINE_SEPARATOR))); |
| | | println(); |
| | | } |
| | |
| | | { |
| | | cancelled = !askConfirmation( |
| | | ERR_REPLICATION_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE. |
| | | get(Utils.getMessageFromCollection(exceptionMsgs, |
| | | get(getMessageFromCollection(exceptionMsgs, |
| | | Constants.LINE_SEPARATOR)), true, logger); |
| | | } |
| | | catch (ClientException ce) |
| | |
| | | { |
| | | case NOT_REPLICATED: |
| | | if (!areReplicated(rep1, rep2) && |
| | | Utils.areDnsEqual(rep1.getSuffix().getDN(), |
| | | areDnsEqual(rep1.getSuffix().getDN(), |
| | | rep2.getSuffix().getDN())) |
| | | { |
| | | suffixes.add(rep1.getSuffix().getDN()); |
| | |
| | | break; |
| | | case NOT_FULLY_REPLICATED: |
| | | if (!areFullyReplicated(rep1, rep2) && |
| | | Utils.areDnsEqual(rep1.getSuffix().getDN(), |
| | | areDnsEqual(rep1.getSuffix().getDN(), |
| | | rep2.getSuffix().getDN())) |
| | | { |
| | | suffixes.add(rep1.getSuffix().getDN()); |
| | | } |
| | | break; |
| | | case ALL: |
| | | if (Utils.areDnsEqual(rep1.getSuffix().getDN(), |
| | | if (areDnsEqual(rep1.getSuffix().getDN(), |
| | | rep2.getSuffix().getDN())) |
| | | { |
| | | suffixes.add(rep1.getSuffix().getDN()); |
| | |
| | | ReplicaDescriptor rep2) |
| | | { |
| | | boolean areFullyReplicated = false; |
| | | if (Utils.areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) && |
| | | if (areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) && |
| | | rep1.isReplicated() && rep2.isReplicated() && |
| | | rep1.getServer().isReplicationServer() && |
| | | rep2.getServer().isReplicationServer()) |
| | |
| | | private boolean areReplicated(ReplicaDescriptor rep1, ReplicaDescriptor rep2) |
| | | { |
| | | boolean areReplicated = false; |
| | | if (Utils.areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) && |
| | | if (areDnsEqual(rep1.getSuffix().getDN(), rep2.getSuffix().getDN()) && |
| | | rep1.isReplicated() && rep2.isReplicated()) |
| | | { |
| | | Set<String> servers1 = rep1.getReplicationServers(); |
| | |
| | | |
| | | LinkedList<LocalizableMessage> errorMessages = new LinkedList<LocalizableMessage>(); |
| | | |
| | | printlnProgress(); |
| | | printProgress( |
| | | println(); |
| | | print( |
| | | formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get())); |
| | | try |
| | | { |
| | |
| | | if (errorMessages.isEmpty()) |
| | | { |
| | | // This done is for the message informing that we are connecting. |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | |
| | | // If we are not in interactive mode do some checks... |
| | | if (!argParser.isInteractive()) |
| | |
| | | { |
| | | if (!argParser.skipReplicationPortCheck() && |
| | | uData.configureReplicationServer1() && |
| | | Utils.isLocalHost(host1) && |
| | | isLocalHost(host1) && |
| | | !SetupUtils.canUseAsPort(replPort1)) |
| | | { |
| | | errorMessages.add(getCannotBindToPortError(replPort1)); |
| | |
| | | { |
| | | if (!argParser.skipReplicationPortCheck() && |
| | | uData.configureReplicationServer2() && |
| | | Utils.isLocalHost(host2) && |
| | | isLocalHost(host2) && |
| | | !SetupUtils.canUseAsPort(replPort2)) |
| | | { |
| | | errorMessages.add(getCannotBindToPortError(replPort2)); |
| | |
| | | |
| | | if (returnValue == SUCCESSFUL) |
| | | { |
| | | long time1 = Utils.getServerClock(ctx1); |
| | | long time2 = Utils.getServerClock(ctx2); |
| | | long time1 = getServerClock(ctx1); |
| | | long time2 = getServerClock(ctx2); |
| | | if ((time1 != -1) && (time2 != -1)) |
| | | { |
| | | if (Math.abs(time1 - time2) > |
| | |
| | | Installer.THRESHOLD_CLOCK_DIFFERENCE_WARNING)); |
| | | } |
| | | } |
| | | printlnProgress(); |
| | | printProgress(INFO_REPLICATION_POST_ENABLE_INFO.get("dsreplication", |
| | | println(); |
| | | println(INFO_REPLICATION_POST_ENABLE_INFO.get("dsreplication", |
| | | ReplicationCliArgumentParser.INITIALIZE_REPLICATION_SUBCMD_NAME)); |
| | | printlnProgress(); |
| | | println(); |
| | | } |
| | | |
| | | close(ctx1, ctx2); |
| | |
| | | { |
| | | ReplicationCliReturnCode returnValue; |
| | | InitialLdapContext ctx = null; |
| | | printProgress( |
| | | print( |
| | | formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get())); |
| | | String bindDn = uData.getAdminUid() == null ? uData.getBindDn() : |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()); |
| | |
| | | if (ctx != null) |
| | | { |
| | | // This done is for the message informing that we are connecting. |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | List<String> suffixes = uData.getBaseDNs(); |
| | | checkSuffixesForDisableReplication(suffixes, ctx, false, |
| | | !uData.disableReplicationServer(), !uData.disableReplicationServer()); |
| | |
| | | { |
| | | try |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | LocalizableMessage msg = formatter.getFormattedProgress( |
| | | INFO_PROGRESS_INITIALIZING_SUFFIX.get(baseDN, |
| | | ConnectionUtils.getHostPort(ctxSource))); |
| | | printProgress(msg); |
| | | printlnProgress(); |
| | | print(msg); |
| | | println(); |
| | | initializeSuffix(baseDN, ctxSource, ctxDestination, true); |
| | | returnValue = SUCCESSFUL; |
| | | } |
| | |
| | | { |
| | | final String hostPort = getServerRepresentation(host, port); |
| | | println(); |
| | | println(Utils.getMessageForException(ne, hostPort)); |
| | | println(getMessageForException(ne, hostPort)); |
| | | logger.error(LocalizableMessage.raw("Complete error stack:"), ne); |
| | | } |
| | | return context; |
| | |
| | | { |
| | | try |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | LocalizableMessage msg = formatter.getFormattedProgress( |
| | | INFO_PROGRESS_INITIALIZING_SUFFIX.get(baseDN, |
| | | ConnectionUtils.getHostPort(ctx))); |
| | | printProgress(msg); |
| | | print(msg); |
| | | println(); |
| | | initializeAllSuffix(baseDN, ctx, true); |
| | | returnValue = SUCCESSFUL; |
| | |
| | | { |
| | | try |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | LocalizableMessage msg = formatter.getFormattedWithPoints( |
| | | INFO_PROGRESS_PRE_EXTERNAL_INITIALIZATION.get(baseDN)); |
| | | printProgress(msg); |
| | | print(msg); |
| | | preExternalInitialization(baseDN, ctx, false); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | catch (ReplicationCliException rce) |
| | | { |
| | |
| | | logger.error(LocalizableMessage.raw("Complete error stack:"), rce); |
| | | } |
| | | } |
| | | printlnProgress(); |
| | | printProgress( |
| | | println(); |
| | | print( |
| | | INFO_PROGRESS_PRE_INITIALIZATION_FINISHED_PROCEDURE.get( |
| | | ReplicationCliArgumentParser. |
| | | POST_EXTERNAL_INITIALIZATION_SUBCMD_NAME)); |
| | | printlnProgress(); |
| | | println(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | try |
| | | { |
| | | printlnProgress(); |
| | | println(); |
| | | LocalizableMessage msg = formatter.getFormattedWithPoints( |
| | | INFO_PROGRESS_POST_EXTERNAL_INITIALIZATION.get(baseDN)); |
| | | printProgress(msg); |
| | | print(msg); |
| | | postExternalInitialization(baseDN, ctx, false); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | println(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | catch (ReplicationCliException rce) |
| | | { |
| | |
| | | logger.error(LocalizableMessage.raw("Complete error stack:"), rce); |
| | | } |
| | | } |
| | | printlnProgress(); |
| | | printProgress( |
| | | println(); |
| | | print( |
| | | INFO_PROGRESS_POST_INITIALIZATION_FINISHED_PROCEDURE.get()); |
| | | printlnProgress(); |
| | | println(); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | for (String s2 : alreadyReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s1, s2)) |
| | | if (areDnsEqual(s1, s2)) |
| | | { |
| | | userProvidedReplicatedSuffixes.add(s1); |
| | | } |
| | |
| | | boolean found = false; |
| | | for (String dn1 : availableSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(dn, dn1)) |
| | | if (areDnsEqual(dn, dn1)) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | boolean isReplicated = false; |
| | | for (String s : alreadyReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s, dn)) |
| | | if (areDnsEqual(s, dn)) |
| | | { |
| | | isReplicated = true; |
| | | break; |
| | |
| | | boolean noSchemaOrAds = false; |
| | | for (String s: availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | noSchemaOrAds = true; |
| | | } |
| | |
| | | println(ERR_NO_SUFFIXES_SELECTED_TO_REPLICATE.get()); |
| | | for (String dn : availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(dn, |
| | | if (!areDnsEqual(dn, |
| | | ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | !areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | for (String s2 : notReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s1, s2)) |
| | | if (areDnsEqual(s1, s2)) |
| | | { |
| | | userProvidedNotReplicatedSuffixes.add(s1); |
| | | } |
| | |
| | | boolean found = false; |
| | | for (String dn1 : availableSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(dn, dn1)) |
| | | if (areDnsEqual(dn, dn1)) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | boolean notReplicated = false; |
| | | for (String s : notReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s, dn)) |
| | | if (areDnsEqual(s, dn)) |
| | | { |
| | | notReplicated = true; |
| | | break; |
| | |
| | | boolean noSchemaOrAds = false; |
| | | for (String s: availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | noSchemaOrAds = true; |
| | | } |
| | |
| | | } |
| | | for (String dn : availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(dn, |
| | | if (!areDnsEqual(dn, |
| | | ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | !areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | try |
| | | { |
| | |
| | | { |
| | | for (String s2 : notReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s1, s2)) |
| | | if (areDnsEqual(s1, s2)) |
| | | { |
| | | userProvidedNotReplicatedSuffixes.add(s1); |
| | | } |
| | |
| | | boolean found = false; |
| | | for (String dn1 : availableSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(dn, dn1)) |
| | | if (areDnsEqual(dn, dn1)) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | boolean notReplicated = false; |
| | | for (String s : notReplicatedSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(s, dn)) |
| | | if (areDnsEqual(s, dn)) |
| | | { |
| | | notReplicated = true; |
| | | break; |
| | |
| | | boolean noSchemaOrAds = false; |
| | | for (String s: availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | noSchemaOrAds = true; |
| | | } |
| | |
| | | } |
| | | for (String dn : availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(dn, |
| | | if (!areDnsEqual(dn, |
| | | ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | !areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | boolean addSuffix; |
| | | try |
| | |
| | | boolean found = false; |
| | | for (String dn1 : availableSuffixes) |
| | | { |
| | | if (Utils.areDnsEqual(dn, dn1)) |
| | | if (areDnsEqual(dn, dn1)) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | boolean noSchemaOrAds = false; |
| | | for (String s: availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | if (!areDnsEqual(s, ADSContext.getAdministrationSuffixDN()) && |
| | | !areDnsEqual(s, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(s, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | noSchemaOrAds = true; |
| | | } |
| | |
| | | |
| | | for (String dn : availableSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(dn, |
| | | if (!areDnsEqual(dn, |
| | | ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | !areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN)) |
| | | { |
| | | try |
| | | { |
| | |
| | | if (!messages.isEmpty()) |
| | | { |
| | | println(ERR_REPLICATION_READING_REGISTERED_SERVERS_WARNING.get( |
| | | Utils.getMessageFromCollection(messages, |
| | | getMessageFromCollection(messages, |
| | | Constants.LINE_SEPARATOR))); |
| | | } |
| | | } |
| | |
| | | boolean adsAlreadyReplicated = false; |
| | | boolean adsMergeDone = false; |
| | | |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_ENABLE_UPDATING_ADS_CONTENTS.get())); |
| | | try |
| | | { |
| | |
| | | } |
| | | else if (!areEqual(registry1, registry2)) |
| | | { |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | |
| | | boolean isFirstSource = mergeRegistries(adsCtx1, adsCtx2); |
| | | if (isFirstSource) |
| | |
| | | if (isADS1Replicated && isADS2Replicated) |
| | | { |
| | | // Merge |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | |
| | | boolean isFirstSource = mergeRegistries(adsCtx1, adsCtx2); |
| | | if (isFirstSource) |
| | |
| | | } |
| | | if (!adsMergeDone) |
| | | { |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | List<String> baseDNs = uData.getBaseDNs(); |
| | | if (!adsAlreadyReplicated) |
| | |
| | | boolean found = false; |
| | | for (String dn : baseDNs) |
| | | { |
| | | if (Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN())) |
| | | if (areDnsEqual(dn, ADSContext.getAdministrationSuffixDN())) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | Set<String> alreadyConfiguredServers = new HashSet<String>(); |
| | | |
| | | if (uData.configureReplicationDomain1() || |
| | | Utils.areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN())) |
| | | areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN())) |
| | | { |
| | | try |
| | | { |
| | |
| | | alreadyConfiguredServers.add(server1.getId()); |
| | | |
| | | if (uData.configureReplicationDomain2() || |
| | | Utils.areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN())) |
| | | areDnsEqual(baseDN, ADSContext.getAdministrationSuffixDN())) |
| | | { |
| | | try |
| | | { |
| | |
| | | if (adsMergeDone) |
| | | { |
| | | PointAdder pointAdder = new PointAdder(this); |
| | | printProgress( |
| | | print( |
| | | INFO_ENABLE_REPLICATION_INITIALIZING_ADS_ALL.get( |
| | | ConnectionUtils.getHostPort(ctxSource))); |
| | | pointAdder.start(); |
| | |
| | | { |
| | | pointAdder.stop(); |
| | | } |
| | | printProgress(formatter.getSpace()); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getSpace()); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | else if ((ctxSource != null) && (ctxDestination != null)) |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_ENABLE_REPLICATION_INITIALIZING_ADS.get( |
| | | ConnectionUtils.getHostPort(ctxDestination), |
| | | ConnectionUtils.getHostPort(ctxSource)))); |
| | | |
| | | initializeSuffix(ADSContext.getAdministrationSuffixDN(), ctxSource, |
| | | ctxDestination, false); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | |
| | | // If we must initialize the schema do so. |
| | |
| | | if (adsMergeDone) |
| | | { |
| | | PointAdder pointAdder = new PointAdder(this); |
| | | printProgress( |
| | | println( |
| | | INFO_ENABLE_REPLICATION_INITIALIZING_SCHEMA.get( |
| | | ConnectionUtils.getHostPort(ctxDestination), |
| | | ConnectionUtils.getHostPort(ctxSource))); |
| | |
| | | { |
| | | pointAdder.stop(); |
| | | } |
| | | printProgress(formatter.getSpace()); |
| | | print(formatter.getSpace()); |
| | | } |
| | | else |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_ENABLE_REPLICATION_INITIALIZING_SCHEMA.get( |
| | | ConnectionUtils.getHostPort(ctxDestination), |
| | | ConnectionUtils.getHostPort(ctxSource)))); |
| | | initializeSuffix(Constants.SCHEMA_DN, ctxSource, |
| | | ctxDestination, false); |
| | | } |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | println( |
| | | ERR_REPLICATION_READING_REGISTERED_SERVERS_WARNING.get( |
| | | Utils.getMessageFromCollection(messages, |
| | | getMessageFromCollection(messages, |
| | | Constants.LINE_SEPARATOR))); |
| | | } |
| | | } |
| | |
| | | |
| | | for (SuffixDescriptor suffix : cache.getSuffixes()) |
| | | { |
| | | if (Utils.areDnsEqual(suffix.getDN(), |
| | | if (areDnsEqual(suffix.getDN(), |
| | | ADSContext.getAdministrationSuffixDN()) || |
| | | Utils.areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN)) |
| | | areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN)) |
| | | { |
| | | // Do not display these suffixes. |
| | | continue; |
| | |
| | | Set<String> baseDNs = new LinkedHashSet<String>(); |
| | | for (SuffixDescriptor suffix : beforeLastRepServer) |
| | | { |
| | | if (!Utils.areDnsEqual(suffix.getDN(), |
| | | if (!areDnsEqual(suffix.getDN(), |
| | | ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN)) |
| | | !areDnsEqual(suffix.getDN(), Constants.SCHEMA_DN)) |
| | | { |
| | | // Do not display these suffixes. |
| | | baseDNs.add(suffix.getDN()); |
| | |
| | | boolean baseDNSpecified = false; |
| | | for (String baseDN : uData.getBaseDNs()) |
| | | { |
| | | if (Utils.areDnsEqual(baseDN, |
| | | if (areDnsEqual(baseDN, |
| | | ADSContext.getAdministrationSuffixDN()) || |
| | | Utils.areDnsEqual(baseDN, Constants.SCHEMA_DN)) |
| | | areDnsEqual(baseDN, Constants.SCHEMA_DN)) |
| | | { |
| | | // Do not display these suffixes. |
| | | continue; |
| | | } |
| | | if (Utils.areDnsEqual(baseDN, suffix.getDN())) |
| | | if (areDnsEqual(baseDN, suffix.getDN())) |
| | | { |
| | | baseDNSpecified = true; |
| | | break; |
| | |
| | | String dn = rep.getSuffix().getDN(); |
| | | if (rep.isReplicated()) |
| | | { |
| | | if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | { |
| | | adsReplicated = true; |
| | | } |
| | | else if (Utils.areDnsEqual(Constants.SCHEMA_DN, dn)) |
| | | else if (areDnsEqual(Constants.SCHEMA_DN, dn)) |
| | | { |
| | | schemaReplicated = true; |
| | | } |
| | |
| | | } |
| | | for (String dn : uData.getBaseDNs()) |
| | | { |
| | | if (Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | if (areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn)) |
| | | { |
| | | // The user already asked this to be explicitly disabled |
| | | forceDisableADS = false; |
| | | } |
| | | else if (Utils.areDnsEqual(Constants.SCHEMA_DN, dn)) |
| | | else if (areDnsEqual(Constants.SCHEMA_DN, dn)) |
| | | { |
| | | // The user already asked this to be explicitly disabled |
| | | forceDisableSchema = false; |
| | |
| | | try |
| | | { |
| | | // Delete all contents from ADSContext. |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_REMOVE_ADS_CONTENTS.get())); |
| | | adsCtx.removeAdminData(false /* avoid self-disconnect */); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | catch (ADSContextException adce) |
| | | { |
| | |
| | | { |
| | | LocalizableMessage msg = |
| | | ERR_REPLICATION_STATUS_READING_REGISTERED_SERVERS.get( |
| | | Utils.getMessageFromCollection(messages, |
| | | getMessageFromCollection(messages, |
| | | Constants.LINE_SEPARATOR)); |
| | | println(msg); |
| | | } |
| | |
| | | // If no base DNs where specified display all the base DNs but the schema |
| | | // and cn=admin data. |
| | | boolean found = displayAll && |
| | | !Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()) && |
| | | !Utils.areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !Utils.areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN); |
| | | !areDnsEqual(dn, ADSContext.getAdministrationSuffixDN()) && |
| | | !areDnsEqual(dn, Constants.SCHEMA_DN) && |
| | | !areDnsEqual(dn, Constants.REPLICATION_CHANGES_DN); |
| | | for (String baseDN : userBaseDNs) |
| | | { |
| | | found = Utils.areDnsEqual(baseDN, dn); |
| | | found = areDnsEqual(baseDN, dn); |
| | | if (found) |
| | | { |
| | | break; |
| | |
| | | { |
| | | ReplicaDescriptor replica = replicas.iterator().next(); |
| | | if (!replica.isReplicated() && |
| | | Utils.areDnsEqual(dn, replica.getSuffix().getDN())) |
| | | areDnsEqual(dn, replica.getSuffix().getDN())) |
| | | { |
| | | replicas.addAll(suffix.getReplicas()); |
| | | found = true; |
| | |
| | | |
| | | if (oneReplicated && !uData.isScriptFriendly()) |
| | | { |
| | | printlnProgress(); |
| | | printProgress(INFO_REPLICATION_STATUS_REPLICATED_LEGEND.get()); |
| | | println(); |
| | | print(INFO_REPLICATION_STATUS_REPLICATED_LEGEND.get()); |
| | | |
| | | if (!replicasWithNoReplicationServer.isEmpty() || |
| | | !serversWithNoReplica.isEmpty()) |
| | | { |
| | | printlnProgress(); |
| | | printProgress( |
| | | println(); |
| | | print( |
| | | INFO_REPLICATION_STATUS_NOT_A_REPLICATION_SERVER_LEGEND.get()); |
| | | |
| | | printlnProgress(); |
| | | printProgress( |
| | | println(); |
| | | print( |
| | | INFO_REPLICATION_STATUS_NOT_A_REPLICATION_DOMAIN_LEGEND.get()); |
| | | } |
| | | printlnProgress(); |
| | | println(); |
| | | somethingDisplayed = true; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (displayAll) |
| | | { |
| | | printProgress(INFO_REPLICATION_STATUS_NO_REPLICATION_INFORMATION.get()); |
| | | printlnProgress(); |
| | | print(INFO_REPLICATION_STATUS_NO_REPLICATION_INFORMATION.get()); |
| | | println(); |
| | | } |
| | | else |
| | | { |
| | | printProgress(INFO_REPLICATION_STATUS_NO_BASEDNS.get()); |
| | | printlnProgress(); |
| | | print(INFO_REPLICATION_STATUS_NO_BASEDNS.get()); |
| | | println(); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | if (scriptFriendly) |
| | | { |
| | | printProgress( |
| | | print( |
| | | INFO_REPLICATION_STATUS_INDEPENDENT_REPLICATION_SERVERS.get()); |
| | | printlnProgress(); |
| | | println(); |
| | | printer = new TabSeparatedTablePrinter(out); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage msg = |
| | | INFO_REPLICATION_STATUS_INDEPENDENT_REPLICATION_SERVERS.get(); |
| | | printProgressMessageNoWrap(msg); |
| | | printlnProgress(); |
| | | print(msg); |
| | | println(); |
| | | int length = msg.length(); |
| | | StringBuilder buf = new StringBuilder(); |
| | | for (int i=0; i<length; i++) |
| | | { |
| | | buf.append("="); |
| | | } |
| | | printProgressMessageNoWrap(LocalizableMessage.raw(buf.toString())); |
| | | printlnProgress(); |
| | | print(LocalizableMessage.raw(buf.toString())); |
| | | println(); |
| | | |
| | | printer = new TextTablePrinter(getOutputStream()); |
| | | ((TextTablePrinter)printer).setColumnSeparator( |
| | |
| | | Set<String> servers = new LinkedHashSet<String>(); |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | if (areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | servers.addAll(replica.getReplicationServers()); |
| | | break; |
| | |
| | | Set<SuffixDescriptor> suffixes = cache.getSuffixes(); |
| | | for (SuffixDescriptor suffix : suffixes) |
| | | { |
| | | if (Utils.areDnsEqual(suffix.getDN(), baseDN)) |
| | | if (areDnsEqual(suffix.getDN(), baseDN)) |
| | | { |
| | | Set<String> s = suffix.getReplicationServers(); |
| | | // Test that at least we share one of the replication servers. |
| | |
| | | Set<String> servers = new LinkedHashSet<String>(); |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | if (areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | servers.addAll(replica.getReplicationServers()); |
| | | break; |
| | |
| | | Set<SuffixDescriptor> suffixes = cache.getSuffixes(); |
| | | for (SuffixDescriptor suffix : suffixes) |
| | | { |
| | | if (Utils.areDnsEqual(suffix.getDN(), baseDN)) |
| | | if (areDnsEqual(suffix.getDN(), baseDN)) |
| | | { |
| | | Set<String> s = suffix.getReplicationServers(); |
| | | // Test that at least we share one of the replication servers. |
| | |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if ((replica.isReplicated()) && |
| | | Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | ids.add(replica.getReplicationId()); |
| | | break; |
| | |
| | | Set<String> replicationServers, |
| | | Set<Integer> usedReplicationServerIds) throws OpenDsException |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_ENABLE_CONFIGURING_REPLICATION_SERVER.get( |
| | | ConnectionUtils.getHostPort(ctx)))); |
| | | |
| | |
| | | replicationServer.commit(); |
| | | } |
| | | |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | |
| | | /** |
| | |
| | | private void updateReplicationServer(InitialLdapContext ctx, |
| | | Set<String> replicationServers) throws OpenDsException |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_ENABLE_UPDATING_REPLICATION_SERVER.get( |
| | | ConnectionUtils.getHostPort(ctx)))); |
| | | |
| | |
| | | replicationServer.commit(); |
| | | } |
| | | |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | for (String dn : l) |
| | | { |
| | | if (Utils.areDnsEqual(dn, ADSContext.getAdministrationSuffixDN())) |
| | | if (areDnsEqual(dn, ADSContext.getAdministrationSuffixDN())) |
| | | { |
| | | userSpecifiedAdminBaseDN = true; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (!userSpecifiedAdminBaseDN && Utils.areDnsEqual(baseDN, |
| | | if (!userSpecifiedAdminBaseDN && areDnsEqual(baseDN, |
| | | ADSContext.getAdministrationSuffixDN())) |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_ENABLE_CONFIGURING_ADS.get( |
| | | ConnectionUtils.getHostPort(ctx)))); |
| | | } |
| | | else |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN.get(baseDN, |
| | | ConnectionUtils.getHostPort(ctx)))); |
| | | } |
| | |
| | | ReplicationDomainCfgClient domain = null; |
| | | for (ReplicationDomainCfgClient domain2 : domains) |
| | | { |
| | | if (Utils.areDnsEqual(baseDN, domain2.getBaseDN().toString())) |
| | | if (areDnsEqual(baseDN, domain2.getBaseDN().toString())) |
| | | { |
| | | domain = domain2; |
| | | break; |
| | |
| | | domain.commit(); |
| | | } |
| | | |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | |
| | | /** |
| | |
| | | filter); |
| | | for (ReplicaDescriptor replica : source.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | if (areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | replicationId = replica.getReplicationId(); |
| | | break; |
| | |
| | | if ((newLogDetails != null) && |
| | | !newLogDetails.toString().trim().equals("")) |
| | | { |
| | | printProgress(newLogDetails); |
| | | printlnProgress(); |
| | | print(newLogDetails); |
| | | println(); |
| | | } |
| | | } |
| | | }); |
| | |
| | | { |
| | | } |
| | | } |
| | | catch (ApplicationException ae) |
| | | catch (ClientException ae) |
| | | { |
| | | throw new ReplicationCliException(ae.getMessageObject(), |
| | | ERROR_INITIALIZING_BASEDN_GENERIC, ae); |
| | |
| | | * initialization is. |
| | | * @param baseDN the dn of the suffix. |
| | | * @param displayProgress whether we want to display progress or not. |
| | | * @throws ApplicationException if an unexpected error occurs. |
| | | * @throws ClientException if an unexpected error occurs. |
| | | * @throws PeerNotFoundException if the replication mechanism cannot find |
| | | * a peer. |
| | | */ |
| | | public void initializeAllSuffixTry(String baseDN, InitialLdapContext ctx, |
| | | boolean displayProgress) |
| | | throws ApplicationException, PeerNotFoundException |
| | | throws ClientException, PeerNotFoundException |
| | | { |
| | | boolean taskCreated = false; |
| | | int i = 1; |
| | |
| | | catch (NamingException ne) |
| | | { |
| | | logger.error(LocalizableMessage.raw("Error creating task "+attrs, ne)); |
| | | throw new ApplicationException( |
| | | throw new ClientException( |
| | | ReturnCode.APPLICATION_ERROR, |
| | | getThrowableMsg(INFO_ERROR_LAUNCHING_INITIALIZATION.get( |
| | | serverDisplay), ne), ne); |
| | |
| | | if (((currentTime - minRefreshPeriod) > lastTimeMsgDisplayed) && |
| | | !msg.equals(lastDisplayedMsg)) |
| | | { |
| | | printProgress(msg); |
| | | print(msg); |
| | | lastDisplayedMsg = msg; |
| | | printlnProgress(); |
| | | println(); |
| | | lastTimeMsgDisplayed = currentTime; |
| | | } |
| | | } |
| | |
| | | logger.info(LocalizableMessage.raw("Last task entry: "+sr)); |
| | | if (displayProgress && (msg != null) && !msg.equals(lastDisplayedMsg)) |
| | | { |
| | | printProgress(msg); |
| | | print(msg); |
| | | lastDisplayedMsg = msg; |
| | | printlnProgress(); |
| | | println(); |
| | | } |
| | | if (lastLogMsg == null) |
| | | { |
| | |
| | | helper.isStoppedByError(state)) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Processed errorMsg: "+errorMsg)); |
| | | ApplicationException ae = new ApplicationException( |
| | | ClientException ce = new ClientException( |
| | | ReturnCode.APPLICATION_ERROR, errorMsg, |
| | | null); |
| | | if ((lastLogMsg == null) || |
| | |
| | | else |
| | | { |
| | | logger.error(LocalizableMessage.raw("Throwing ApplicationException.")); |
| | | throw ae; |
| | | throw ce; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (displayProgress) |
| | | { |
| | | printProgress(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get()); |
| | | printlnProgress(); |
| | | print(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get()); |
| | | println(); |
| | | } |
| | | logger.info(LocalizableMessage.raw("Processed msg: "+errorMsg)); |
| | | logger.info(LocalizableMessage.raw("Initialization completed successfully.")); |
| | |
| | | logger.info(LocalizableMessage.raw("Initialization entry not found.")); |
| | | if (displayProgress) |
| | | { |
| | | printProgress(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get()); |
| | | printlnProgress(); |
| | | print(INFO_SUFFIX_INITIALIZED_SUCCESSFULLY.get()); |
| | | println(); |
| | | } |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | throw new ApplicationException( |
| | | throw new ClientException( |
| | | ReturnCode.APPLICATION_ERROR, |
| | | getThrowableMsg(INFO_ERROR_POOLING_INITIALIZATION.get( |
| | | serverDisplay), ne), ne); |
| | |
| | | for (String baseDN : baseDNs) |
| | | { |
| | | lastBaseDN = baseDN; |
| | | if (Utils.areDnsEqual(domain.getBaseDN().toString(), |
| | | if (areDnsEqual(domain.getBaseDN().toString(), |
| | | baseDN)) |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_REMOVING_REFERENCES_ON_REMOTE.get(baseDN, |
| | | hostPort))); |
| | | Set<String> replServers = domain.getReplicationServer(); |
| | |
| | | } |
| | | } |
| | | } |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | ReplicationDomainCfgClient domain = |
| | | sync.getReplicationDomain(domainName); |
| | | if (Utils.areDnsEqual(domain.getBaseDN().toString(), baseDN)) |
| | | if (areDnsEqual(domain.getBaseDN().toString(), baseDN)) |
| | | { |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_DISABLING_BASEDN.get(baseDN, |
| | | hostPort))); |
| | | sync.removeReplicationDomain(domainName); |
| | | sync.commit(); |
| | | |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (replicationServer != null) |
| | | { |
| | | String s = String.valueOf(replicationServer.getReplicationPort()); |
| | | printProgress(formatter.getFormattedWithPoints( |
| | | print(formatter.getFormattedWithPoints( |
| | | INFO_REPLICATION_DISABLING_REPLICATION_SERVER.get(s, |
| | | hostPort))); |
| | | |
| | | sync.removeReplicationServer(); |
| | | sync.commit(); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | } |
| | | } |
| | | catch (OpenDsException ode) |
| | |
| | | } |
| | | |
| | | /** |
| | | * Prints a message to the output with no wrapping if we are not in quiet |
| | | * mode. |
| | | * @param msg the message to be displayed. |
| | | */ |
| | | private void printProgressMessageNoWrap(LocalizableMessage msg) |
| | | { |
| | | if (!isQuiet()) |
| | | { |
| | | getOutputStream().print(msg.toString()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Forces the initialization of the trust manager in the |
| | | * LDAPConnectionInteraction object. |
| | | */ |
| | |
| | | |
| | | for (String dn1 : replicatedSuffixes) |
| | | { |
| | | if (!Utils.areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn1) && |
| | | !Utils.areDnsEqual(Constants.SCHEMA_DN, dn1)) |
| | | if (!areDnsEqual(ADSContext.getAdministrationSuffixDN(), dn1) && |
| | | !areDnsEqual(Constants.SCHEMA_DN, dn1)) |
| | | { |
| | | boolean found = false; |
| | | for (String dn2 : uData.getBaseDNs()) |
| | | { |
| | | if (Utils.areDnsEqual(dn1, dn2)) |
| | | if (areDnsEqual(dn1, dn2)) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | String adminUID = uData.getAdminUid(); |
| | | if (bindDN1 != null && adminUID != null) |
| | | { |
| | | if (!Utils.areDnsEqual(ADSContext.getAdministratorDN(adminUID), |
| | | if (!areDnsEqual(ADSContext.getAdministratorDN(adminUID), |
| | | bindDN1)) |
| | | { |
| | | forceAddBindDN1 = true; |
| | |
| | | String adminUID = uData.getAdminUid(); |
| | | if (bindDN2 != null && adminUID != null) |
| | | { |
| | | if (!Utils.areDnsEqual(ADSContext.getAdministratorDN(adminUID), |
| | | if (!areDnsEqual(ADSContext.getAdministratorDN(adminUID), |
| | | bindDN2)) |
| | | { |
| | | forceAddBindDN2 = true; |
| | |
| | | boolean isFirstReplicated = false; |
| | | for (SuffixDescriptor suffix2 : cache2.getSuffixes()) |
| | | { |
| | | if (Utils.areDnsEqual(suffix.getDN(), suffix2.getDN())) |
| | | if (areDnsEqual(suffix.getDN(), suffix2.getDN())) |
| | | { |
| | | for (String rServer2 : suffix2.getReplicationServers()) |
| | | { |
| | |
| | | int nReplicationServers = 0; |
| | | for (SuffixDescriptor suffix : suffixes) |
| | | { |
| | | if (Utils.areDnsEqual(suffix.getDN(), baseDN)) |
| | | if (areDnsEqual(suffix.getDN(), baseDN)) |
| | | { |
| | | Set<String> replicationServers = suffix.getReplicationServers(); |
| | | nReplicationServers += replicationServers.size(); |
| | |
| | | println(); |
| | | } |
| | | |
| | | printProgress(INFO_REPLICATION_MERGING_REGISTRIES_PROGRESS.get()); |
| | | print(INFO_REPLICATION_MERGING_REGISTRIES_PROGRESS.get()); |
| | | pointAdder.start(); |
| | | |
| | | Collection<LocalizableMessage> cache1Errors = cache1.getErrorMessages(); |
| | |
| | | throw new ReplicationCliException( |
| | | ERR_REPLICATION_CANNOT_MERGE_WITH_ERRORS.get( |
| | | ConnectionUtils.getHostPort(adsCtx1.getDirContext()), |
| | | Utils.getMessageFromCollection(cache1Errors, |
| | | getMessageFromCollection(cache1Errors, |
| | | Constants.LINE_SEPARATOR)), |
| | | ERROR_READING_ADS, null); |
| | | } |
| | |
| | | throw new ReplicationCliException( |
| | | ERR_REPLICATION_CANNOT_MERGE_WITH_ERRORS.get( |
| | | ConnectionUtils.getHostPort(adsCtx2.getDirContext()), |
| | | Utils.getMessageFromCollection(cache2Errors, |
| | | getMessageFromCollection(cache2Errors, |
| | | Constants.LINE_SEPARATOR)), |
| | | ERROR_READING_ADS, null); |
| | | } |
| | |
| | | boolean found = false; |
| | | for (SuffixDescriptor suffix2 : cache2.getSuffixes()) |
| | | { |
| | | if (!Utils.areDnsEqual(suffix2.getDN(), |
| | | if (!areDnsEqual(suffix2.getDN(), |
| | | replica1.getSuffix().getDN())) |
| | | { |
| | | // Conflicting domain names must apply to same suffix. |
| | |
| | | if (!commonRepServerIDErrors.isEmpty()) |
| | | { |
| | | mb.append(ERR_REPLICATION_ENABLE_COMMON_REPLICATION_SERVER_ID.get( |
| | | Utils.getMessageFromCollection(commonRepServerIDErrors, |
| | | getMessageFromCollection(commonRepServerIDErrors, |
| | | Constants.LINE_SEPARATOR))); |
| | | } |
| | | if (!commonDomainIDErrors.isEmpty()) |
| | |
| | | mb.append(Constants.LINE_SEPARATOR); |
| | | } |
| | | mb.append(ERR_REPLICATION_ENABLE_COMMON_DOMAIN_ID.get( |
| | | Utils.getMessageFromCollection(commonDomainIDErrors, |
| | | getMessageFromCollection(commonDomainIDErrors, |
| | | Constants.LINE_SEPARATOR))); |
| | | } |
| | | throw new ReplicationCliException(mb.toMessage(), |
| | |
| | | ERROR_SEEDING_TRUSTORE, t); |
| | | } |
| | | pointAdder.stop(); |
| | | printProgress(formatter.getSpace()); |
| | | printProgress(formatter.getFormattedDone()); |
| | | printlnProgress(); |
| | | print(formatter.getSpace()); |
| | | print(formatter.getFormattedDone()); |
| | | println(); |
| | | |
| | | return adsCtxSource == adsCtx1; |
| | | } |
| | |
| | | boolean isReplicated = false; |
| | | for (ReplicaDescriptor replica : server.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | if (areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | isReplicated = replica.isReplicated(); |
| | | break; |
| | |
| | | ReplicaDescriptor replica2; |
| | | for (ReplicaDescriptor replica : server1.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | if (areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | replica1 = replica; |
| | | break; |
| | |
| | | { |
| | | for (ReplicaDescriptor replica : server2.getReplicas()) |
| | | { |
| | | if (Utils.areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | if (areDnsEqual(replica.getSuffix().getDN(), baseDN)) |
| | | { |
| | | replica2 = replica; |
| | | if (replica2.isReplicated()) |