mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
18.00.2015 94e9037522922b67e8af412b4cfe476f5e991118
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 */
 
package org.opends.guitools.uninstaller;
 
import java.io.IOException;
import java.util.Iterator;
 
import org.opends.admin.ads.ADSContext;
import org.opends.quicksetup.Configuration;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.util.Utils;
 
/**
 * This is a convenience class used to represent the current configuraton and
 * status of the server to know which kind of questions we must ask to the user
 * (the server is running, it is configured for replication, it contains an
 * ADS...).
 *
 * The difference with Installation class is that it provides read only
 * information that is computed in the constructor of the class and not
 * on demand.  This way we can construct the object outside the event thread
 * and then read it inside the event thread without blocking the display.
 */
public class UninstallData
{
  private boolean isServerRunning;
  private boolean isADS;
  private boolean isReplicationServer;
  private int replicationServerPort;
 
  /**
   * The constructor for UninstallData.
   * @param installation the object describing the installation.
   * @throws IOException if there was an error retrieving the current
   * installation configuration.
   */
  public UninstallData(Installation installation) throws IOException
  {
    isServerRunning = installation.getStatus().isServerRunning();
    Configuration conf = new Configuration(installation,
        installation.getCurrentConfigurationFile());
    Iterator<String> it = conf.getBaseDNs().iterator();
    while (it.hasNext() && !isADS)
    {
      isADS = Utils.areDnsEqual(it.next(),
          ADSContext.getAdministrationSuffixDN());
    }
    isReplicationServer = conf.isReplicationServer();
    replicationServerPort = conf.getReplicationPort();
  }
 
  /**
   * Returns whether this server is configured as an ADS or not.
   * @return <CODE>true</CODE> if the server is configured as an ADS and
   * <CODE>false</CODE> otherwise.
   */
  public boolean isADS() {
    return isADS;
  }
 
  /**
   * Returns whether this server is configured as a replication server or not.
   * @return <CODE>true</CODE> if the server is configured as a replication
   * server and <CODE>false</CODE> otherwise.
   */
  public boolean isReplicationServer() {
    return isReplicationServer;
  }
 
  /**
   * Returns whether this server is running or not.
   * @return <CODE>true</CODE> if the server is running and <CODE>false</CODE>
   * otherwise.
   */
  public boolean isServerRunning() {
    return isServerRunning;
  }
 
  /**
   * Returns the port of the replication server.  -1 if it is not defined.
   * @return the port of the replication server.  -1 if it is not defined.
   */
  public int getReplicationServerPort() {
    return replicationServerPort;
  }
}