| | |
| | | |
| | | package org.opends.quicksetup; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.Map; |
| | | |
| | | import org.opends.admin.ads.ServerDescriptor; |
| | | import org.opends.admin.ads.SuffixDescriptor; |
| | | import org.opends.quicksetup.installer.AuthenticationData; |
| | | import org.opends.quicksetup.installer.DataReplicationOptions; |
| | |
| | | { |
| | | private String serverLocation; |
| | | |
| | | private String hostName; |
| | | |
| | | private int serverPort; |
| | | |
| | | private String directoryManagerDn; |
| | |
| | | |
| | | private SuffixesToReplicateOptions suffixesToReplicateOptions; |
| | | |
| | | private Map<ServerDescriptor, Integer> remoteWithNoReplicationPort; |
| | | |
| | | private boolean silent; |
| | | |
| | | private boolean noninteractive; |
| | |
| | | setServerPort(defaultPort); |
| | | } |
| | | |
| | | setHostName(getDefaultHostName()); |
| | | |
| | | setDirectoryManagerDn(Constants.DIRECTORY_MANAGER_DN); |
| | | |
| | | setNewSuffixOptions(defaultNewSuffixOptions); |
| | |
| | | data.setDn(Constants.DIRECTORY_MANAGER_DN); |
| | | data.setPort(389); |
| | | DataReplicationOptions repl = new DataReplicationOptions( |
| | | DataReplicationOptions.Type.STANDALONE, data); |
| | | DataReplicationOptions.Type.STANDALONE, data, |
| | | getDefaultReplicationPort()); |
| | | setReplicationOptions(repl); |
| | | setGlobalAdministratorUID("admin"); |
| | | |
| | |
| | | setSuffixesToReplicateOptions(suffixes); |
| | | SecurityOptions sec = SecurityOptions.createNoCertificateOptions(); |
| | | sec.setSslPort(getDefaultSslPort()); |
| | | sec.setCertificateUserName(getDefaultSelfSignedName()); |
| | | setSecurityOptions(sec); |
| | | |
| | | remoteWithNoReplicationPort = new HashMap<ServerDescriptor, Integer>(); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets the host name. |
| | | * @param hostName the server host name. |
| | | */ |
| | | public void setHostName(String hostName) |
| | | { |
| | | this.hostName = hostName; |
| | | } |
| | | |
| | | /** |
| | | * Returns the server host name. |
| | | * @return the server host name. |
| | | */ |
| | | public String getHostName() |
| | | { |
| | | return hostName; |
| | | } |
| | | |
| | | /** |
| | | * Sets the server LDAP port. |
| | | * @param serverPort the new server LDAP port. |
| | | */ |
| | |
| | | } |
| | | return defaultJMXPort; |
| | | } |
| | | |
| | | /** |
| | | * Provides the default name for the self signed certificate that will be |
| | | * created. |
| | | * Provides the port that will be proposed to the user in the replication |
| | | * options panel of the installation wizard. It will check whether we can use |
| | | * ports of type X989 and if not it will return -1. |
| | | * |
| | | * @return the free port of type X989 if it is available and we can use and -1 |
| | | * if not. |
| | | */ |
| | | private String getDefaultSelfSignedName() |
| | | static int getDefaultReplicationPort() |
| | | { |
| | | int defaultPort = -1; |
| | | |
| | | for (int i=0;i<10000 && (defaultPort == -1);i+=1000) |
| | | { |
| | | int port = i + 8989; |
| | | if (Utils.canUseAsPort(port)) |
| | | { |
| | | defaultPort = port; |
| | | } |
| | | } |
| | | return defaultPort; |
| | | } |
| | | |
| | | /** |
| | | * Provides the default host name that will be displayed. |
| | | */ |
| | | private String getDefaultHostName() |
| | | { |
| | | String name = ""; |
| | | try |
| | |
| | | } |
| | | return name; |
| | | } |
| | | |
| | | /** |
| | | * Returns a Map containing as key a ServerDescriptor and as value an Integer |
| | | * corresponding to the Replication Port chosen by the user. |
| | | * |
| | | * Only the servers that have no replication port appear on this map. |
| | | * @return a Map containing as key a ServerDescriptor and as value an Integer |
| | | * corresponding to the Replication Port chosen by the user. |
| | | */ |
| | | public Map<ServerDescriptor, Integer> getRemoteWithNoReplicationPort() |
| | | { |
| | | HashMap<ServerDescriptor, Integer> copy = |
| | | new HashMap<ServerDescriptor, Integer>(); |
| | | copy.putAll(remoteWithNoReplicationPort); |
| | | return copy; |
| | | } |
| | | |
| | | /** |
| | | * Sets a the Replication Ports chosen by the user in the remote servers. |
| | | * @param remoteWithNoReplicationPort the Map containing as key a |
| | | * ServerDescriptor and as value an Integer corresponding to the Replication |
| | | * Port chosen by the user. |
| | | */ |
| | | public void setRemoteWithNoReplicationPort( |
| | | Map<ServerDescriptor, Integer> remoteWithNoReplicationPort) |
| | | { |
| | | this.remoteWithNoReplicationPort.clear(); |
| | | this.remoteWithNoReplicationPort.putAll(remoteWithNoReplicationPort); |
| | | } |
| | | } |