001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008-2009 Sun Microsystems, Inc.
025 *      Portions Copyright 2015 ForgeRock AS.
026 */
027package org.opends.server.tools.dsreplication;
028
029/**
030 * This class is used to store the information provided by the user to enable
031 * replication.  It is required because when we are in interactive mode the
032 * ReplicationCliArgumentParser is not enough.
033 */
034public class EnableReplicationUserData extends ReplicationUserData
035{
036  /** Data for enabling replication on a server. */
037  static final class EnableReplicationServerData
038  {
039    private String hostName;
040    private int port;
041    private String bindDn;
042    private String pwd;
043    private int replicationPort;
044    private boolean secureReplication;
045    private boolean configureReplicationServer = true;
046    private boolean configureReplicationDomain = true;
047
048    /**
049     * Returns the host name of this server.
050     *
051     * @return the host name of this server.
052     */
053    String getHostName()
054    {
055      return hostName;
056    }
057
058    /**
059     * Sets the host name of this server.
060     *
061     * @param hostName
062     *          the host name of this server
063     */
064    void setHostName(String hostName)
065    {
066      this.hostName = hostName;
067    }
068
069    /**
070     * Returns the port of this server.
071     *
072     * @return the port of this server
073     */
074    int getPort()
075    {
076      return port;
077    }
078
079    /**
080     * Sets the port of this server.
081     *
082     * @param port
083     *          the port of this server
084     */
085    void setPort(int port)
086    {
087      this.port = port;
088    }
089
090    /**
091     * Returns the password for this server.
092     *
093     * @return the password for this server
094     */
095    String getPwd()
096    {
097      return pwd;
098    }
099
100    /**
101     * Sets the password for this server.
102     *
103     * @param pwd
104     *          the password for this server
105     */
106    void setPwd(String pwd)
107    {
108      this.pwd = pwd;
109    }
110
111    /**
112     * Returns the dn to be used to bind to this server.
113     *
114     * @return the dn to be used to bind to this server
115     */
116    String getBindDn()
117    {
118      return bindDn;
119    }
120
121    /**
122     * Sets the dn to be used to bind to this server.
123     *
124     * @param bindDn
125     *          the dn to be used to bind to this server
126     */
127    void setBindDn(String bindDn)
128    {
129      this.bindDn = bindDn;
130    }
131
132    /**
133     * Returns the replication port to be used on this server if it is not defined yet.
134     *
135     * @return the replication port to be used on this server if it is not defined yet
136     */
137    int getReplicationPort()
138    {
139      return replicationPort;
140    }
141
142    /**
143     * Sets the replication port to be used on this server if it is not defined yet.
144     *
145     * @param replicationPort
146     *          the replication port to be used on this server if it is not defined yet.
147     */
148    void setReplicationPort(int replicationPort)
149    {
150      this.replicationPort = replicationPort;
151    }
152
153    /**
154     * Returns whether the user asked to have secure replication communication with this server.
155     *
156     * @return {@code true} if the user asked to have secure replication communication with the
157     *         second server, {@code false} otherwise.
158     */
159    boolean isSecureReplication()
160    {
161      return secureReplication;
162    }
163
164    /**
165     * Sets whether to use secure replication communication with this server.
166     *
167     * @param secureReplication
168     *          whether to use secure replication communication with this server .
169     */
170    void setSecureReplication(boolean secureReplication)
171    {
172      this.secureReplication = secureReplication;
173    }
174
175    /**
176     * Returns whether the user asked to configure the replication server on this server.
177     *
178     * @return whether the user asked to configure the replication server on this server
179     */
180    boolean configureReplicationServer()
181    {
182      return configureReplicationServer;
183    }
184
185    /**
186     * Sets whether to configure the replication server on this server.
187     *
188     * @param configureReplicationServer
189     *          whether to configure the replication server on this server
190     */
191    void setConfigureReplicationServer(boolean configureReplicationServer)
192    {
193      this.configureReplicationServer = configureReplicationServer;
194    }
195
196    /**
197     * Returns whether the user asked to configure the replication domain on this server.
198     *
199     * @return whether the user asked to configure the replication domain on this server
200     */
201    boolean configureReplicationDomain()
202    {
203      return configureReplicationDomain;
204    }
205
206    /**
207     * Sets whether to configure the replication domain on this server.
208     *
209     * @param configureReplicationDomain
210     *          whether to configure the replication domain on this server
211     */
212    void setConfigureReplicationDomain(boolean configureReplicationDomain)
213    {
214      this.configureReplicationDomain = configureReplicationDomain;
215    }
216  }
217
218  private EnableReplicationServerData server1 = new EnableReplicationServerData();
219  private EnableReplicationServerData server2 = new EnableReplicationServerData();
220  private boolean replicateSchema = true;
221
222  /**
223   * Returns <CODE>true</CODE> if the user asked to replicate schema and <CODE>
224   * false</CODE> otherwise.
225   * @return <CODE>true</CODE> if the user asked to replicate schema and <CODE>
226   * false</CODE> otherwise.
227   */
228  public boolean replicateSchema()
229  {
230    return replicateSchema;
231  }
232
233  /**
234   * Sets whether to replicate schema or not.
235   * @param replicateSchema whether to replicate schema or not.
236   */
237  public void setReplicateSchema(boolean replicateSchema)
238  {
239    this.replicateSchema = replicateSchema;
240  }
241
242  /**
243   * Returns the data for enabling replication on first server.
244   *
245   * @return the data for enabling replication on first server
246   */
247  EnableReplicationServerData getServer1()
248  {
249    return server1;
250  }
251
252  /**
253   * Returns the data for enabling replication on second server.
254   *
255   * @return the data for enabling replication on second server
256   */
257  EnableReplicationServerData getServer2()
258  {
259    return server2;
260  }
261}