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