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 */
027
028package org.opends.server.tools.dsreplication;
029
030import org.opends.server.types.HostPort;
031
032/**
033 * This class is used to store the information provided by the user to
034 * initialize replication.  It is required because when we are in interactive
035 * mode the ReplicationCliArgumentParser is not enough.
036 */
037public class SourceDestinationServerUserData extends ReplicationUserData
038{
039  private String hostNameSource;
040  private int portSource;
041  private String hostNameDestination;
042  private int portDestination;
043
044  /**
045   * Returns the host name of the source server.
046   * @return the host name of the source server.
047   */
048  public String getHostNameSource()
049  {
050    return hostNameSource;
051  }
052
053  /**
054   * Sets the host name of the source server.
055   * @param hostNameSource the host name of the source server.
056   */
057  public void setHostNameSource(String hostNameSource)
058  {
059    this.hostNameSource = hostNameSource;
060  }
061
062  /**
063   * Returns the port of the source server.
064   * @return the port of the source server.
065   */
066  public int getPortSource()
067  {
068    return portSource;
069  }
070
071  /**
072   * Sets the port of the source server.
073   * @param portSource the port of the source server.
074   */
075  public void setPortSource(int portSource)
076  {
077    this.portSource = portSource;
078  }
079
080  /**
081   * Returns the host name of the destination server.
082   * @return the host name of the destination server.
083   */
084  public String getHostNameDestination()
085  {
086    return new HostPort(hostNameDestination, portDestination).toString();
087  }
088
089  /**
090   * Returns a host:port string for the source server.
091   * @return a host:port string for the source server
092   */
093  public String getSourceHostPort()
094  {
095    return new HostPort(hostNameSource, portSource).toString();
096  }
097
098  /**
099   * Returns a host:port string for the destination server.
100   * @return a host:port string for the destination server
101   */
102  public String getDestinationHostPort()
103  {
104    return hostNameDestination + ":" + portDestination;
105  }
106
107  /**
108   * Sets the host name of the destination server.
109   * @param hostNameDestination the host name of the destination server.
110   */
111  public void setHostNameDestination(String hostNameDestination)
112  {
113    this.hostNameDestination = hostNameDestination;
114  }
115
116  /**
117   * Returns the port of the destination server.
118   * @return the port of the destination server.
119   */
120  public int getPortDestination()
121  {
122    return portDestination;
123  }
124
125  /**
126   * Sets the port of the destination server.
127   * @param portDestination the port of the destination server.
128   */
129  public void setPortDestination(int portDestination)
130  {
131    this.portDestination = portDestination;
132  }
133
134  /**
135   * Returns a {@link HostPort} representing the source server.
136   * @return a {@link HostPort} representing the source server
137   */
138  public HostPort getSource()
139  {
140    return new HostPort(hostNameSource, portSource);
141  }
142
143  /**
144   * Returns a {@link HostPort} representing the destination server.
145   * @return a {@link HostPort} representing the destination server
146   */
147  public HostPort getDestination()
148  {
149    return new HostPort(hostNameDestination, portDestination);
150  }
151}