opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionWrapper.java
@@ -38,6 +38,7 @@ import org.forgerock.opendj.config.LDAPProfile; import org.forgerock.opendj.ldap.Connection; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.LDAPConnectionFactory; import org.forgerock.opendj.ldap.LdapException; import org.forgerock.opendj.ldap.SSLContextBuilder; @@ -63,6 +64,8 @@ private final Connection connection; private final InitialLdapContext ldapContext; private final HostPort hostPort; private DN bindDn; private String bindPwd; private final int connectTimeout; private final TrustManager trustManager; private final KeyManager keyManager; @@ -152,6 +155,8 @@ int connectTimeout, TrustManager trustManager, KeyManager keyManager) throws NamingException { this.hostPort = hostPort; this.bindDn = DN.valueOf(bindDn); this.bindPwd = bindPwd; this.connectTimeout = connectTimeout; this.trustManager = trustManager; this.keyManager = keyManager; @@ -196,6 +201,36 @@ } } /** * Returns the bind DN used by this connection. * * @return the bind DN used by this connection. */ public DN getBindDn() { return bindDn; } /** * Returns the bind password used by this connection. * * @return the bind password used by this connection. */ public String getBindPassword() { return bindPwd; } /** * Returns the LDAP URL used by the InitialLdapContext. * * @return the LDAP URL used by the InitialLdapContext. */ public String getLdapUrl() { return ConnectionUtils.getLdapUrl(ldapContext); } private InitialLdapContext createAdministrativeContext(Options options, String bindDn, String bindPwd) throws NamingException { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/BackendDescriptor.java
@@ -21,6 +21,7 @@ import java.util.SortedSet; import java.util.TreeSet; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.admin.ads.ADSContext; /** The class that describes the backend configuration. */ @@ -33,7 +34,7 @@ private int entries; private final boolean isConfigBackend; private final boolean isEnabled; private CustomSearchResult monitoringEntry; private SearchResultEntry monitoringEntry; private final Type type; private PluggableType pluggableType; private int hashCode; @@ -164,7 +165,7 @@ * Returns the monitoring entry information. * @return the monitoring entry information. */ public CustomSearchResult getMonitoringEntry() public SearchResultEntry getMonitoringEntry() { return monitoringEntry; } @@ -268,11 +269,11 @@ /** * Sets the monitoring entry corresponding to this backend. * @param monitoringEntry the monitoring entry corresponding to this backend. * @param sr the monitoring entry corresponding to this backend. */ public void setMonitoringEntry(CustomSearchResult monitoringEntry) public void setMonitoringEntry(SearchResultEntry sr) { this.monitoringEntry = monitoringEntry; this.monitoringEntry = sr; } /** opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ConnectionHandlerDescriptor.java
@@ -26,6 +26,7 @@ import java.util.TreeSet; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.server.config.meta.AdministrationConnectorCfgDefn; /** @@ -34,7 +35,7 @@ */ public class ConnectionHandlerDescriptor { private Set<CustomSearchResult> monitoringEntries = Collections.emptySet(); private Set<SearchResultEntry> monitoringEntries = Collections.emptySet(); /** Enumeration used to represent the state of the listener. */ public enum State @@ -120,7 +121,7 @@ */ public ConnectionHandlerDescriptor(Collection<InetAddress> addresses, int port, Protocol protocol, State state, String name, Set<CustomSearchResult> monitoringEntries) Set<SearchResultEntry> monitoringEntries) { this.addresses.addAll(addresses); this.port = port; @@ -171,7 +172,7 @@ * Returns the monitoring entries. * @return the monitoring entries. */ public Set<CustomSearchResult> getMonitoringEntries() public Set<SearchResultEntry> getMonitoringEntries() { return monitoringEntries; } @@ -180,7 +181,7 @@ * Sets the monitoring entries. * @param monitoringEntries the monitoring entries. */ public void setMonitoringEntries(Set<CustomSearchResult> monitoringEntries) public void setMonitoringEntries(Set<SearchResultEntry> monitoringEntries) { this.monitoringEntries = Collections.unmodifiableSet(monitoringEntries); } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ConnectionHandlersMonitoringTableModel.java
@@ -16,6 +16,8 @@ */ package org.opends.guitools.controlpanel.datamodel; import static org.opends.messages.AdminToolMessages.*; import java.net.InetAddress; import java.util.ArrayList; import java.util.HashSet; @@ -23,11 +25,9 @@ import java.util.Set; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor.Protocol; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; /** The table model used to display the monitoring information of connection handlers. */ public class ConnectionHandlersMonitoringTableModel extends MonitoringTableModel<ConnectionHandlerDescriptor, @@ -101,7 +101,7 @@ } @Override protected CustomSearchResult getMonitoringEntry( protected SearchResultEntry getMonitoringEntry( AddressConnectionHandlerDescriptor ach) { return ach.getMonitoringEntry(); @@ -140,12 +140,11 @@ return sb.toString(); } private CustomSearchResult getMonitoringEntry(InetAddress address, ConnectionHandlerDescriptor cch) private SearchResultEntry getMonitoringEntry(InetAddress address, ConnectionHandlerDescriptor cch) { for (CustomSearchResult sr : cch.getMonitoringEntries()) for (SearchResultEntry sr : cch.getMonitoringEntries()) { String cn = getFirstValueAsString(sr, "cn"); String cn = sr.getAttribute("cn").firstValueAsString(); if (cn != null) { if (address == null) @@ -176,7 +175,7 @@ { private final ConnectionHandlerDescriptor ch; private final InetAddress address; private final CustomSearchResult monitoringEntry; private final SearchResultEntry monitoringEntry; private final int hashCode; /** @@ -188,7 +187,7 @@ public AddressConnectionHandlerDescriptor( ConnectionHandlerDescriptor ch, InetAddress address, CustomSearchResult monitoringEntry) SearchResultEntry monitoringEntry) { this.ch = ch; this.address = address; @@ -226,7 +225,7 @@ * Returns the monitoring entry. * @return the monitoring entry. */ public CustomSearchResult getMonitoringEntry() public SearchResultEntry getMonitoringEntry() { return monitoringEntry; } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -16,13 +16,13 @@ */ package org.opends.guitools.controlpanel.datamodel; import static org.opends.admin.ads.util.ConnectionUtils.*; import static org.opends.admin.ads.util.PreferredConnection.Type.*; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.server.tools.ConfigureWindowsService.*; import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import static org.opends.admin.ads.util.ConnectionUtils.*; import static org.opends.admin.ads.util.PreferredConnection.Type.*; import static org.opends.server.tools.ConfigureWindowsService.*; import java.io.File; import java.net.InetAddress; import java.util.Collection; @@ -298,11 +298,10 @@ this.connWrapper = connWrapper; if (connWrapper != null) { InitialLdapContext ctx = connWrapper.getLdapContext(); lastWorkingBindDN = ConnectionUtils.getBindDN(ctx); lastWorkingBindPwd = ConnectionUtils.getBindPassword(ctx); lastWorkingBindDN = connWrapper.getBindDn().toString(); lastWorkingBindPwd = connWrapper.getBindPassword(); lastRemoteHostName = connWrapper.getHostPort().getHost(); lastRemoteAdministrationURL = ConnectionUtils.getLdapUrl(ctx); lastRemoteAdministrationURL = connWrapper.getLdapUrl(); } } @@ -498,7 +497,7 @@ Utilities.initializeConfigurationFramework(); reader = newRemoteConfigReader(); boolean connectionWorks = checkConnections(connWrapper.getLdapContext(), userDataCtx); boolean connectionWorks = checkConnections(connWrapper, userDataCtx); if (!connectionWorks) { if (isLocal) @@ -532,13 +531,13 @@ desc.setJvmMemoryUsageMonitor(rCtx.getJvmMemoryUsage()); desc.setSystemInformationMonitor(rCtx.getSystemInformation()); desc.setWorkQueueMonitor(rCtx.getWorkQueue()); desc.setOpenDSVersion(getFirstValueAsString(rCtx.getVersionMonitor(), "fullVersion")); String installPath = getFirstValueAsString(rCtx.getSystemInformation(), "installPath"); desc.setOpenDSVersion(rCtx.getVersionMonitor().getAttribute("fullVersion").firstValueAsString()); String installPath = rCtx.getSystemInformation().getAttribute("installPath").firstValueAsString(); if (installPath != null) { desc.setInstallPath(installPath); } String instancePath = getFirstValueAsString(rCtx.getSystemInformation(), "instancePath"); String instancePath = rCtx.getSystemInformation().getAttribute("instancePath").firstValueAsString(); if (instancePath != null) { desc.setInstancePath(instancePath); @@ -1195,7 +1194,7 @@ return adminPort1 == adminPort2; } private boolean checkConnections(InitialLdapContext ctx, InitialLdapContext userCtx) private boolean checkConnections(ConnectionWrapper conn, InitialLdapContext userCtx) { // Check the connection int nMaxErrors = 5; @@ -1203,7 +1202,7 @@ { try { Utilities.pingDirContext(ctx); Utilities.ping(conn); if (userCtx != null) { Utilities.pingDirContext(userCtx); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/DatabaseMonitoringTableModel.java
@@ -16,6 +16,10 @@ */ package org.opends.guitools.controlpanel.datamodel; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.server.util.CollectionUtils.*; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -26,10 +30,7 @@ import java.util.TreeSet; import org.forgerock.i18n.LocalizableMessage; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.server.util.CollectionUtils.*; import org.forgerock.opendj.ldap.responses.SearchResultEntry; /** The table model used to display all the database monitoring information. */ public class DatabaseMonitoringTableModel extends SortableTableModel implements Comparator<BackendDescriptor> @@ -112,8 +113,8 @@ @Override public int compare(BackendDescriptor desc1, BackendDescriptor desc2) { CustomSearchResult monitor1 = desc1.getMonitoringEntry(); CustomSearchResult monitor2 = desc2.getMonitoringEntry(); SearchResultEntry monitor1 = desc1.getMonitoringEntry(); SearchResultEntry monitor2 = desc2.getMonitoringEntry(); ArrayList<Integer> possibleResults = newArrayList(getName(desc1).compareTo(getName(desc2))); computeMonitoringPossibleResults(monitor1, monitor2, possibleResults, attributes); @@ -286,7 +287,7 @@ * @return the monitoring entry associated with the provided backend. Returns * <CODE>null</CODE> if there is no monitoring entry associated. */ private CustomSearchResult getMonitoringEntry(BackendDescriptor backend) private SearchResultEntry getMonitoringEntry(BackendDescriptor backend) { return backend.getMonitoringEntry(); } @@ -296,18 +297,11 @@ String[] line = new String[attributes.size() + 1]; line[0] = getName(backend); int i = 1; CustomSearchResult monitoringEntry = getMonitoringEntry(backend); SearchResultEntry monitoringEntry = getMonitoringEntry(backend); for (String attr : attributes) { String o = getFirstValueAsString(monitoringEntry, attr); if (o != null) { line[i] = o; } else { line[i] = NO_VALUE_SET.toString(); } String o = monitoringEntry.getAttribute(attr).firstValueAsString(); line[i] = o != null ? o : NO_VALUE_SET.toString(); i++; } return line; opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/MonitoringTableModel.java
@@ -16,6 +16,9 @@ */ package org.opends.guitools.controlpanel.datamodel; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -26,11 +29,9 @@ import java.util.TreeSet; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.util.Utilities; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; /** * The abstract table model used to display all the network groups. * @param <T> the type of the objects passed externally to the table model. @@ -290,18 +291,17 @@ * @return the monitoring entry associated with the provided object. Returns * <CODE>null</CODE> if there is no monitoring entry associated. */ protected abstract CustomSearchResult getMonitoringEntry(P o); protected abstract SearchResultEntry getMonitoringEntry(P o); private String[] getLine(P o) { String[] line = new String[columnNames.length]; line[0] = getName(o); int i = 1; CustomSearchResult monitoringEntry = getMonitoringEntry(o); SearchResultEntry monitoringEntry = getMonitoringEntry(o); for (MonitoringAttributes attribute : attributes) { line[i] = Utilities.getMonitoringValue( attribute, monitoringEntry); line[i] = Utilities.getMonitoringValue(attribute, monitoringEntry); if (showAverages && attribute.canHaveAverage()) { i++; @@ -355,8 +355,8 @@ * @return a list of integer with all the values of two monitoring entries * compared. */ protected ArrayList<Integer> getMonitoringPossibleResults( CustomSearchResult monitor1, CustomSearchResult monitor2) protected List<Integer> getMonitoringPossibleResults( SearchResultEntry monitor1, SearchResultEntry monitor2) { final List<String> attrs = new ArrayList<>(); for (MonitoringAttributes operation : getAttributes()) opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -27,6 +27,7 @@ import java.util.Set; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.opends.guitools.controlpanel.util.ConfigFromDirContext; @@ -37,7 +38,6 @@ import com.forgerock.opendj.util.OperatingSystem; import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.server.types.CommonSchemaElements.*; /** @@ -63,11 +63,11 @@ private boolean isSchemaEnabled; private Schema schema; private CustomSearchResult rootMonitor; private CustomSearchResult jvmMemoryUsage; private CustomSearchResult systemInformation; private CustomSearchResult entryCaches; private CustomSearchResult workQueue; private SearchResultEntry rootMonitor; private SearchResultEntry jvmMemoryUsage; private SearchResultEntry systemInformation; private SearchResultEntry entryCaches; private SearchResultEntry workQueue; private Set<TaskEntry> taskEntries = new HashSet<>(); @@ -508,12 +508,12 @@ { return OperatingSystem.isWindows(); } CustomSearchResult sr = getSystemInformationMonitor(); SearchResultEntry sr = getSystemInformationMonitor(); if (sr == null) { return false; } String os = getFirstValueAsString(sr, "operatingSystem"); String os = sr.getAttribute("operatingSystem").firstValueAsString(); return os != null && OperatingSystem.WINDOWS.equals(OperatingSystem.forName(os)); } @@ -692,7 +692,7 @@ * Sets the monitoring entry for the entry caches. * @param entryCaches the monitoring entry for the entry caches. */ public void setEntryCachesMonitor(CustomSearchResult entryCaches) public void setEntryCachesMonitor(SearchResultEntry entryCaches) { this.entryCaches = entryCaches; } @@ -701,7 +701,7 @@ * Sets the monitoring entry for the JVM memory usage. * @param jvmMemoryUsage the monitoring entry for the JVM memory usage. */ public void setJvmMemoryUsageMonitor(CustomSearchResult jvmMemoryUsage) public void setJvmMemoryUsageMonitor(SearchResultEntry jvmMemoryUsage) { this.jvmMemoryUsage = jvmMemoryUsage; } @@ -710,20 +710,20 @@ * Sets the root entry of the monitoring tree. * @param rootMonitor the root entry of the monitoring tree. */ public void setRootMonitor(CustomSearchResult rootMonitor) public void setRootMonitor(SearchResultEntry rootMonitor) { this.rootMonitor = rootMonitor; runningTime = computeRunningTime(rootMonitor); } private long computeRunningTime(CustomSearchResult rootMonitor) private long computeRunningTime(SearchResultEntry rootMonitor) { if (rootMonitor != null) { try { String start = getFirstValueAsString(rootMonitor, START_DATE.getAttributeName()); String current = getFirstValueAsString(rootMonitor, CURRENT_DATE.getAttributeName()); String start = rootMonitor.getAttribute(START_DATE.getAttributeName()).firstValueAsString(); String current = rootMonitor.getAttribute(CURRENT_DATE.getAttributeName()).firstValueAsString(); Date startTime = ConfigFromDirContext.utcParser.parse(start); Date currentTime = ConfigFromDirContext.utcParser.parse(current); return currentTime.getTime() - startTime.getTime(); @@ -750,7 +750,7 @@ * Sets the monitoring entry for the system information. * @param systemInformation entry for the system information. */ public void setSystemInformationMonitor(CustomSearchResult systemInformation) public void setSystemInformationMonitor(SearchResultEntry systemInformation) { this.systemInformation = systemInformation; } @@ -759,7 +759,7 @@ * Sets the monitoring entry of the work queue. * @param workQueue entry of the work queue. */ public void setWorkQueueMonitor(CustomSearchResult workQueue) public void setWorkQueueMonitor(SearchResultEntry workQueue) { this.workQueue = workQueue; } @@ -768,7 +768,7 @@ * Returns the monitoring entry for the entry caches. * @return the monitoring entry for the entry caches. */ public CustomSearchResult getEntryCachesMonitor() public SearchResultEntry getEntryCachesMonitor() { return entryCaches; } @@ -777,7 +777,7 @@ * Returns the monitoring entry for the JVM memory usage. * @return the monitoring entry for the JVM memory usage. */ public CustomSearchResult getJvmMemoryUsageMonitor() public SearchResultEntry getJvmMemoryUsageMonitor() { return jvmMemoryUsage; } @@ -786,7 +786,7 @@ * Returns the root entry of the monitoring tree. * @return the root entry of the monitoring tree. */ public CustomSearchResult getRootMonitor() public SearchResultEntry getRootMonitor() { return rootMonitor; } @@ -795,7 +795,7 @@ * Returns the monitoring entry for the system information. * @return the monitoring entry for the system information. */ public CustomSearchResult getSystemInformationMonitor() public SearchResultEntry getSystemInformationMonitor() { return systemInformation; } @@ -804,7 +804,7 @@ * Returns the monitoring entry for the work queue. * @return the monitoring entry for the work queue. */ public CustomSearchResult getWorkQueueMonitor() public SearchResultEntry getWorkQueueMonitor() { return workQueue; } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java
@@ -53,6 +53,7 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; @@ -60,7 +61,6 @@ import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor.State; import org.opends.guitools.controlpanel.datamodel.ConnectionHandlersMonitoringTableModel; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; @@ -199,7 +199,7 @@ { Set<InetAddress> addresses = new HashSet<>(); addresses.add(InetAddress.getLocalHost()); Set<CustomSearchResult> emptySet = Collections.emptySet(); Set<SearchResultEntry> emptySet = Collections.emptySet(); for (String name : names) { fakeData.add(new ConnectionHandlerDescriptor( opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/ControlCenterMainPane.java
@@ -32,13 +32,13 @@ import javax.swing.JSplitPane; import javax.swing.SwingUtilities; import org.opends.admin.ads.util.ConnectionUtils; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.DN; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.event.ConfigChangeListener; import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; import org.opends.guitools.controlpanel.util.Utilities; import org.forgerock.i18n.LocalizableMessage; /** * The main panel of the control panel. It contains a split pane. On the left @@ -177,8 +177,7 @@ { try { String bindDN = ConnectionUtils.getBindDN( statusPane.getInfo().getConnection().getLdapContext()); DN bindDN = statusPane.getInfo().getConnection().getBindDn(); lAuthenticatedAs.setText( INFO_CTRL_PANEL_AUTHENTICATED_AS.get(bindDN).toString()); } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DatabaseMonitoringPanel.java
@@ -36,6 +36,7 @@ import javax.swing.SwingConstants; import javax.swing.table.DefaultTableCellRenderer; import org.forgerock.opendj.ldap.Attribute; import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; import org.opends.guitools.controlpanel.datamodel.BackendDescriptor.PluggableType; import org.opends.guitools.controlpanel.datamodel.DatabaseMonitoringTableModel; @@ -229,9 +230,9 @@ Set<String> attrNames = new HashSet<>(); if (backend.getMonitoringEntry() != null) { Set<String> allNames = backend.getMonitoringEntry().getAttributeNames(); for (String attrName : allNames) for (Attribute attribute : backend.getMonitoringEntry().getAllAttributes()) { String attrName = attribute.getAttributeDescriptionAsString(); if (!attrName.equalsIgnoreCase(ServerConstants.OBJECTCLASS_ATTRIBUTE_TYPE_NAME) && !attrName.equalsIgnoreCase(ServerConstants.ATTR_COMMON_NAME)) { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/EntryCachesMonitoringPanel.java
@@ -24,14 +24,13 @@ import javax.swing.Box; import javax.swing.JLabel; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.util.Utilities; import org.opends.server.util.CollectionUtils; import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; /** The panel displaying the entry caches monitor panel. */ @@ -123,18 +122,18 @@ { server = getInfo().getServerDescriptor(); } CustomSearchResult csr = null; SearchResultEntry sr = null; if (server != null) { csr = server.getEntryCachesMonitor(); sr = server.getEntryCachesMonitor(); } if (csr != null) if (sr != null) { updateMonitoringInfo(ngOperations, monitoringLabels, csr); updateMonitoringInfo(ngOperations, monitoringLabels, sr); int index = 0; for (MonitoringAttributes attr : ngOperations) { if (getFirstValueAsString(csr, attr.getAttributeName()) == null) if (sr.getAttribute(attr.getAttributeName()).firstValueAsString() == null) { monitoringLabels.get(index).setVisible(false); labels.get(index).setVisible(false); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/JavaInformationMonitoringPanel.java
@@ -21,7 +21,6 @@ import java.awt.GridBagLayout; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -35,14 +34,14 @@ import javax.swing.event.ChangeListener; import javax.swing.text.JTextComponent; import org.forgerock.opendj.ldap.Attribute; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.ui.components.BasicExpander; import org.opends.guitools.controlpanel.util.Utilities; import org.opends.server.util.CollectionUtils; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.server.util.ServerConstants.*; @@ -276,8 +275,8 @@ { server = getInfo().getServerDescriptor(); } CustomSearchResult csrSystem = null; CustomSearchResult csrMemory = null; SearchResultEntry csrSystem = null; SearchResultEntry csrMemory = null; if (server != null) { csrSystem = server.getSystemInformationMonitor(); @@ -326,10 +325,10 @@ { if (memoryAttributes.isEmpty()) { Set<String> allNames = csrMemory.getAttributeNames(); SortedSet<String> sortedNames = new TreeSet<>(); for (String attrName : allNames) for (Attribute attribute : csrMemory.getAllAttributes()) { String attrName = attribute.getAttributeDescriptionAsString(); if (!OBJECTCLASS_ATTRIBUTE_TYPE_NAME.equalsIgnoreCase(attrName) && !ATTR_COMMON_NAME.equalsIgnoreCase(attrName)) { @@ -368,7 +367,7 @@ for (int i=0; i<memoryAttributes.size() ; i++) { String value = getFirstValueAsString(csrMemory, memoryAttributes.get(i)); String value = csrMemory.getAttribute(memoryAttributes.get(i)).firstValueAsString(); if (value != null) { memoryLabels.get(i).setText(value); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
@@ -28,11 +28,7 @@ import java.util.Iterator; import java.util.LinkedHashSet; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import javax.naming.ldap.InitialLdapContext; import javax.swing.Box; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; @@ -45,13 +41,14 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.admin.ads.util.ApplicationTrustManager; import org.opends.admin.ads.util.ConnectionUtils; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.guitools.controlpanel.ControlPanelArgumentParser; import org.opends.guitools.controlpanel.datamodel.ConfigReadException; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent; import org.opends.guitools.controlpanel.task.OnlineUpdateException; import org.opends.guitools.controlpanel.util.BackgroundTask; @@ -62,7 +59,6 @@ import org.opends.quicksetup.ui.CertificateDialog; import org.opends.quicksetup.util.UIKeyStore; import org.opends.quicksetup.util.Utils; import org.opends.server.monitors.VersionMonitorProvider; import org.opends.server.types.HostPort; import org.opends.server.types.OpenDsException; import org.opends.server.util.DynamicConstants; @@ -70,8 +66,9 @@ import static com.forgerock.opendj.cli.Utils.*; import static org.forgerock.opendj.ldap.SearchScope.*; import static org.forgerock.opendj.ldap.requests.Requests.*; import static org.opends.admin.ads.util.PreferredConnection.Type.*; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.messages.QuickSetupMessages.*; import static org.opends.server.monitors.VersionMonitorProvider.*; @@ -552,7 +549,7 @@ usedUrl = ConnectionUtils.getLDAPUrl(hostPort, true); conn = new ConnectionWrapper(hostPort, LDAPS, dn.getText(), String.valueOf(pwd.getPassword()), info.getConnectTimeout(), info.getTrustManager()); checkVersion(conn.getLdapContext()); checkVersion(conn); } StaticUtils.sleep(500); @@ -867,45 +864,22 @@ t.start(); } private void checkVersion(InitialLdapContext ctx) throws OpenDsException private void checkVersion(ConnectionWrapper conn) throws OpenDsException { LocalizableMessage msg = null; try { // Search for the version on the remote server. SearchControls searchControls = new SearchControls(); searchControls.setSearchScope( SearchControls.OBJECT_SCOPE); searchControls.setReturningAttributes( new String[] { VersionMonitorProvider.ATTR_PRODUCT_NAME, VersionMonitorProvider.ATTR_MAJOR_VERSION, VersionMonitorProvider.ATTR_POINT_VERSION, VersionMonitorProvider.ATTR_MINOR_VERSION }); NamingEnumeration<SearchResult> en = ctx.search("cn=Version,cn=monitor", "objectclass=*", searchControls); SearchResult sr = null; try { while (en.hasMore()) { sr = en.next(); } } finally { en.close(); } SearchRequest request = newSearchRequest( "cn=Version,cn=monitor", BASE_OBJECT, "objectclass=*", ATTR_PRODUCT_NAME, ATTR_MAJOR_VERSION, ATTR_POINT_VERSION, ATTR_MINOR_VERSION); SearchResultEntry sr = conn.getConnection().searchSingleEntry(request); CustomSearchResult csr = new CustomSearchResult(sr, "cn=Version,cn=monitor"); String hostName = ConnectionUtils.getHostName(ctx); String productName = getFirstValueAsString(csr, ATTR_PRODUCT_NAME); String major = getFirstValueAsString(csr, ATTR_MAJOR_VERSION); String point = getFirstValueAsString(csr, ATTR_POINT_VERSION); String minor = getFirstValueAsString(csr, ATTR_MINOR_VERSION); String hostName = conn.getHostPort().getHost(); String productName = sr.getAttribute(ATTR_PRODUCT_NAME).firstValueAsString(); String major = sr.getAttribute(ATTR_MAJOR_VERSION).firstValueAsString(); String point = sr.getAttribute(ATTR_POINT_VERSION).firstValueAsString(); String minor = sr.getAttribute(ATTR_MINOR_VERSION).firstValueAsString(); // Be strict, control panel is only compatible with exactly the same version if (!productName.equalsIgnoreCase(DynamicConstants.PRODUCT_NAME)) { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/RootMonitoringPanel.java
@@ -24,14 +24,13 @@ import javax.swing.JLabel; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.util.ConfigFromDirContext; import org.opends.guitools.controlpanel.util.Utilities; import static org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes.*; import static org.opends.guitools.controlpanel.util.Utilities.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.messages.BackendMessages.*; @@ -127,12 +126,12 @@ { server = getInfo().getServerDescriptor(); } CustomSearchResult csr = null; SearchResultEntry sr = null; if (server != null) { csr = server.getRootMonitor(); sr = server.getRootMonitor(); } if (csr != null) if (sr != null) { JLabel[] ls = { @@ -150,13 +149,13 @@ }; for (int i=0; i<ls.length; i++) { ls[i].setText(getMonitoringValue(attrs[i], csr)); ls[i].setText(getMonitoringValue(attrs[i], sr)); } version.setText(server.getOpenDSVersion()); try { String start = getFirstValueAsString(csr, START_DATE.getAttributeName()); String current = getFirstValueAsString(csr, CURRENT_DATE.getAttributeName()); String start = sr.getAttribute(START_DATE.getAttributeName()).firstValueAsString(); String current = sr.getAttribute(CURRENT_DATE.getAttributeName()).firstValueAsString(); Date startTime = ConfigFromDirContext.utcParser.parse(start); Date currentTime = ConfigFromDirContext.utcParser.parse(current); opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -67,6 +67,8 @@ import org.forgerock.i18n.LocalizableMessageBuilder; import org.forgerock.i18n.LocalizableMessageDescriptor; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.forgerock.opendj.ldap.schema.ObjectClassType; import org.opends.admin.ads.util.ConnectionUtils; import org.opends.guitools.controlpanel.browser.BrowserController; @@ -76,7 +78,6 @@ import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement; import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.ScheduleType; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; @@ -95,7 +96,6 @@ import org.opends.guitools.controlpanel.util.Utilities; import org.opends.quicksetup.ui.CustomHTMLEditorKit; import org.opends.server.schema.SchemaConstants; import org.forgerock.opendj.ldap.schema.ObjectClass; import org.opends.server.types.OpenDsException; import org.opends.server.util.ServerConstants; import org.opends.server.util.StaticUtils; @@ -2096,7 +2096,7 @@ * the monitoring entry. * @return the monitoring value in a String form to be displayed to the user. */ public static String getMonitoringValue(final MonitoringAttributes attr, final CustomSearchResult monitoringEntry) public static String getMonitoringValue(final MonitoringAttributes attr, final SearchResultEntry monitoringEntry) { return Utilities.getMonitoringValue(attr, monitoringEntry); } @@ -2112,7 +2112,7 @@ * the monitoring entry containing the information to be displayed. */ protected void updateMonitoringInfo(final List<? extends MonitoringAttributes> monitoringAttrs, final List<JLabel> monitoringLabels, final CustomSearchResult monitoringEntry) final List<JLabel> monitoringLabels, final SearchResultEntry monitoringEntry) { for (int i = 0; i < monitoringAttrs.size(); i++) { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/SystemInformationMonitoringPanel.java
@@ -26,8 +26,8 @@ import javax.swing.Box; import javax.swing.JLabel; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.MonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.util.Utilities; @@ -120,14 +120,14 @@ { server = getInfo().getServerDescriptor(); } CustomSearchResult csr = null; SearchResultEntry sr = null; if (server != null) { csr = server.getSystemInformationMonitor(); sr = server.getSystemInformationMonitor(); } if (csr != null) if (sr != null) { updateMonitoringInfo(operations, monitoringLabels, csr); updateMonitoringInfo(operations, monitoringLabels, sr); } else { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/WorkQueueMonitoringPanel.java
@@ -26,8 +26,8 @@ import javax.swing.Box; import javax.swing.JLabel; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.opends.guitools.controlpanel.datamodel.BasicMonitoringAttributes; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.ServerDescriptor; import org.opends.guitools.controlpanel.util.Utilities; import org.opends.server.util.CollectionUtils; @@ -118,14 +118,14 @@ { server = getInfo().getServerDescriptor(); } CustomSearchResult csr = null; SearchResultEntry sr = null; if (server != null) { csr = server.getWorkQueueMonitor(); sr = server.getWorkQueueMonitor(); } if (csr != null) if (sr != null) { updateMonitoringInfo(attributes, monitoringLabels, csr); updateMonitoringInfo(attributes, monitoringLabels, sr); } else { opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -16,9 +16,13 @@ */ package org.opends.guitools.controlpanel.util; import static org.forgerock.opendj.ldap.SearchScope.*; import static org.forgerock.opendj.ldap.requests.Requests.*; import static org.opends.messages.AdminToolMessages.*; import static org.opends.server.backends.pluggable.SuffixContainer.*; import static org.opends.server.config.ConfigConstants.*; import java.io.IOException; import java.net.InetAddress; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -29,22 +33,23 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.SortedSet; import java.util.TimeZone; import java.util.TreeSet; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import javax.naming.ldap.InitialLdapContext; import javax.naming.ldap.LdapName; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.LocalizedIllegalArgumentException; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.adapter.server3x.Converters; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.ldap.Attribute; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.LdapException; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldif.ConnectionEntryReader; import org.forgerock.opendj.server.config.client.AdministrationConnectorCfgClient; import org.forgerock.opendj.server.config.client.BackendCfgClient; import org.forgerock.opendj.server.config.client.BackendIndexCfgClient; @@ -67,18 +72,15 @@ import org.forgerock.opendj.server.config.client.RootDNUserCfgClient; import org.forgerock.opendj.server.config.client.SNMPConnectionHandlerCfgClient; import org.forgerock.opendj.server.config.client.TaskBackendCfgClient; import org.opends.admin.ads.util.ConnectionUtils; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; import org.opends.guitools.controlpanel.task.OnlineUpdateException; import org.opends.server.config.ConfigConstants; import org.opends.server.core.DirectoryServer; import org.opends.server.tools.tasks.TaskEntry; import org.opends.server.types.OpenDsException; @@ -96,16 +98,16 @@ private static final String DATABASE_PDB_MONITORING_ENTRY_SUFFIX = " PDB Database"; private static final String SYNC_PROVIDER_NAME = "Multimaster Synchronization"; private CustomSearchResult rootMonitor; private CustomSearchResult jvmMemoryUsage; private CustomSearchResult systemInformation; private CustomSearchResult entryCaches; private CustomSearchResult workQueue; private CustomSearchResult versionMonitor; private SearchResultEntry rootMonitor; private SearchResultEntry jvmMemoryUsage; private SearchResultEntry systemInformation; private SearchResultEntry entryCaches; private SearchResultEntry workQueue; private SearchResultEntry versionMonitor; private boolean isLocal = true; private final Map<String, CustomSearchResult> hmConnectionHandlersMonitor = new HashMap<>(); private final Map<String, SearchResultEntry> hmConnectionHandlersMonitor = new HashMap<>(); /** The monitor root entry DN. */ private DN monitorDN = DN.rootDN(); @@ -150,7 +152,7 @@ * * @return the monitoring entry for the entry caches. */ public CustomSearchResult getEntryCaches() public SearchResultEntry getEntryCaches() { return entryCaches; } @@ -160,7 +162,7 @@ * * @return the monitoring entry for the JVM memory usage. */ public CustomSearchResult getJvmMemoryUsage() public SearchResultEntry getJvmMemoryUsage() { return jvmMemoryUsage; } @@ -170,7 +172,7 @@ * * @return the root entry of the monitoring tree. */ public CustomSearchResult getRootMonitor() public SearchResultEntry getRootMonitor() { return rootMonitor; } @@ -180,7 +182,7 @@ * * @return the version entry of the monitoring tree. */ public CustomSearchResult getVersionMonitor() public SearchResultEntry getVersionMonitor() { return versionMonitor; } @@ -190,7 +192,7 @@ * * @return the monitoring entry for the system information. */ public CustomSearchResult getSystemInformation() public SearchResultEntry getSystemInformation() { return systemInformation; } @@ -200,7 +202,7 @@ * * @return the monitoring entry for the work queue. */ public CustomSearchResult getWorkQueue() public SearchResultEntry getWorkQueue() { return workQueue; } @@ -254,7 +256,7 @@ hmConnectionHandlersMonitor.clear(); readSchemaIfNeeded(connWrapper.getLdapContext(), errors); readSchemaIfNeeded(connWrapper, errors); try { @@ -274,7 +276,7 @@ backends = Collections.unmodifiableSet(backendDescriptors); try { updateMonitorInformation(connWrapper.getLdapContext(), errors); updateMonitorInformation(connWrapper, errors); } catch (Throwable t) { @@ -284,7 +286,7 @@ try { updateTaskInformation(connWrapper.getLdapContext(), errors, tasks); updateTaskInformation(connWrapper, errors, tasks); } catch (Throwable t) { @@ -305,13 +307,13 @@ exceptions = Collections.unmodifiableList(errors); } private void readSchemaIfNeeded(final InitialLdapContext context, final List<Exception> errors) private void readSchemaIfNeeded(final ConnectionWrapper connWrapper, final List<Exception> errors) { if (mustReadSchema()) { try { readSchema(context); readSchema(connWrapper); if (getSchema() != null) { // Update the schema: so that when we call the server code the @@ -553,7 +555,7 @@ ConnectionHandlerDescriptor.Protocol protocol = isReplicationSecure ? ConnectionHandlerDescriptor.Protocol.REPLICATION_SECURE : ConnectionHandlerDescriptor.Protocol.REPLICATION; Set<CustomSearchResult> emptySet = Collections.emptySet(); Set<SearchResultEntry> emptySet = Collections.emptySet(); ConnectionHandlerDescriptor connHandler = new ConnectionHandlerDescriptor( new HashSet<InetAddress>(), replicationPort, protocol, ConnectionHandlerDescriptor.State.ENABLED, SYNC_PROVIDER_NAME, emptySet); @@ -624,12 +626,12 @@ /** * Reads the schema from the files. * * @param ctx * @param connWrapper * the connection to be used to load the schema. * @throws OpenDsException * if an error occurs reading the schema. */ private void readSchema(InitialLdapContext ctx) throws OpenDsException private void readSchema(ConnectionWrapper connWrapper) throws OpenDsException { try { @@ -640,17 +642,17 @@ else { RemoteSchemaLoader loader = new RemoteSchemaLoader(); loader.readSchema(ctx); loader.readSchema(connWrapper); schema = loader.getSchema(); } } catch (NamingException ne) catch (LdapException e) { throw new OnlineUpdateException(ERR_READING_SCHEMA_LDAP.get(ne), ne); throw new OnlineUpdateException(ERR_READING_SCHEMA_LDAP.get(e), e); } catch (ConfigException ce) catch (ConfigException e) { throw new org.opends.server.config.ConfigException(ce.getMessageObject(), ce); throw new org.opends.server.config.ConfigException(e.getMessageObject(), e); } } @@ -660,55 +662,55 @@ * * @param sr * the search result. * @param searchBaseDN * the base search. * @throws NamingException * @throws LdapException * if there is an error retrieving the values of the search result. */ private void handleMonitoringSearchResult(SearchResult sr, String searchBaseDN) throws NamingException private void handleMonitoringSearchResult(SearchResultEntry sr) throws LdapException { if (javaVersion == null) { javaVersion = ConnectionUtils.getFirstValue(sr, "javaVersion"); Attribute attr = sr.getAttribute("javaVersion"); javaVersion = attr != null ? attr.firstValueAsString() : null; } if (numberConnections == -1) { String v = ConnectionUtils.getFirstValue(sr, "currentConnections"); if (v != null) Integer nb = sr.getAttribute("currentConnections").parse().asInteger(); if (nb != null) { numberConnections = Integer.parseInt(v); numberConnections = nb; } } String dn = ConnectionUtils.getFirstValue(sr, "domain-name"); String replicaId = ConnectionUtils.getFirstValue(sr, "server-id"); String missingChanges = ConnectionUtils.getFirstValue(sr, "missing-changes"); Attribute dnAttr = sr.getAttribute("domain-name"); Attribute replicaIdAttr = sr.getAttribute("server-id"); Attribute missingChanges = sr.getAttribute("missing-changes"); if (dn != null && replicaId != null && missingChanges != null) if (dnAttr != null && replicaIdAttr != null && missingChanges != null) { DN dn = dnAttr.parse().asDN(); Integer replicaId = replicaIdAttr.parse().asInteger(); for (BackendDescriptor backend : backends) { for (BaseDNDescriptor baseDN : backend.getBaseDns()) { try { if (baseDN.getDn().equals(DN.valueOf(dn)) && Integer.toString(baseDN.getReplicaID()).equals(replicaId)) if (baseDN.getDn().equals(dn) && Objects.equals(baseDN.getReplicaID(), replicaId)) { try { baseDN.setAgeOfOldestMissingChange( Long.valueOf(ConnectionUtils.getFirstValue(sr, "approx-older-change-not-synchronized-millis"))); sr.getAttribute("approx-older-change-not-synchronized-millis").parse().asLong()); } catch (Throwable ignored) catch (NullPointerException | LocalizedIllegalArgumentException ignored) { } try { baseDN.setMissingChanges(Integer.valueOf(missingChanges)); baseDN.setMissingChanges(missingChanges.parse().asInteger()); } catch (Throwable ignored) catch (NullPointerException | LocalizedIllegalArgumentException ignored) { } } @@ -721,38 +723,34 @@ } else { CustomSearchResult csr = new CustomSearchResult(sr, searchBaseDN); String backendID = ConnectionUtils.getFirstValue(sr, "ds-backend-id"); String entryCount = ConnectionUtils.getFirstValue(sr, "ds-backend-entry-count"); Set<String> baseDnEntries = ConnectionUtils.getValues(sr, "ds-base-dn-entry-count"); if (backendID != null && (entryCount != null || baseDnEntries != null)) Attribute backendIdAttr = sr.getAttribute("ds-backend-id"); Attribute entryCount = sr.getAttribute("ds-backend-entry-count"); Attribute baseDnEntriesAttr = sr.getAttribute("ds-base-dn-entry-count"); if (backendIdAttr != null && (entryCount != null || !baseDnEntriesAttr.isEmpty())) { String backendID = backendIdAttr.firstValueAsString(); Set<String> baseDnEntries = baseDnEntriesAttr.parse().asSetOfString(); for (BackendDescriptor backend : backends) { if (backend.getBackendID().equalsIgnoreCase(backendID)) { if (entryCount != null) { backend.setEntries(Integer.parseInt(entryCount)); backend.setEntries(entryCount.parse().asInteger()); } if (baseDnEntries != null) { for (String s : baseDnEntries) { int index = s.indexOf(" "); if (index != -1) { DN dn = DN.valueOf(s.substring(index + 1)); for (BaseDNDescriptor baseDN : backend.getBaseDns()) { dn = s.substring(index +1); if (Utilities.areDnsEqual(dn, baseDN.getDn().toString())) if (dn.equals(baseDN.getDn())) { try { baseDN.setEntries( Integer.parseInt(s.substring(0, index))); baseDN.setEntries(Integer.parseInt(s.substring(0, index))); } catch (Throwable t) { @@ -766,11 +764,10 @@ } } } } else { // Check if it is the DB monitor entry String cn = ConnectionUtils.getFirstValue(sr, "cn"); String cn = sr.getAttribute("cn").firstValueAsString(); String monitorBackendID = null; BackendDescriptor.PluggableType pluggableType = BackendDescriptor.PluggableType.UNKNOWN; if (cn != null && cn.endsWith(DATABASE_JE_MONITORING_ENTRY_SUFFIX)) @@ -790,46 +787,46 @@ if (backend.getBackendID().equalsIgnoreCase(monitorBackendID)) { backend.setPluggableType(pluggableType); backend.setMonitoringEntry(csr); backend.setMonitoringEntry(sr); } } } } try { if (rootMonitor == null && isRootMonitor(csr)) if (rootMonitor == null && isRootMonitor(sr)) { rootMonitor = csr; rootMonitor = sr; } else if (entryCaches == null && isEntryCaches(csr)) else if (entryCaches == null && isEntryCaches(sr)) { entryCaches = csr; entryCaches = sr; } else if (workQueue == null && isWorkQueue(csr)) else if (workQueue == null && isWorkQueue(sr)) { workQueue = csr; workQueue = sr; } else if (jvmMemoryUsage == null && isJvmMemoryUsage(csr)) else if (jvmMemoryUsage == null && isJvmMemoryUsage(sr)) { jvmMemoryUsage = csr; jvmMemoryUsage = sr; } else if (systemInformation == null && isSystemInformation(csr)) else if (systemInformation == null && isSystemInformation(sr)) { systemInformation = csr; systemInformation = sr; } else if (versionMonitor == null && isVersionMonitor(csr)) else if (versionMonitor == null && isVersionMonitor(sr)) { versionMonitor = csr; versionMonitor = sr; } else if (isConnectionHandler(csr)) else if (isConnectionHandler(sr)) { String statistics = " Statistics"; String cn = ConnectionUtils.getFirstValue(sr, "cn"); String cn = sr.getAttribute("cn").firstValueAsString(); if (cn.endsWith(statistics)) { // Assume it is a connection handler String name = cn.substring(0, cn.length() - statistics.length()); hmConnectionHandlersMonitor.put(getKey(name), csr); hmConnectionHandlersMonitor.put(getKey(name), sr); } } } @@ -841,70 +838,49 @@ } /** * Takes the provided search result and updates the task information * accordingly. * Takes the provided search result and updates the task information accordingly. * * @param sr * the search result. * @param searchBaseDN * the base search. * @param taskEntries * the collection of TaskEntries to be updated. * @param ex * the list of exceptions to be updated if an error occurs. * @throws NamingException * if there is an error retrieving the values of the search result. */ private void handleTaskSearchResult(SearchResult sr, String searchBaseDN, Collection<TaskEntry> taskEntries, List<Exception> ex) throws NamingException private void handleTaskSearchResult(SearchResultEntry sr, Collection<TaskEntry> taskEntries, List<Exception> ex) { CustomSearchResult csr = new CustomSearchResult(sr, searchBaseDN); try { if (isTaskEntry(csr)) if (isTaskEntry(sr)) { taskEntries.add(new TaskEntry(csr.getEntry())); taskEntries.add(new TaskEntry(Converters.to(sr))); } } catch (OpenDsException ode) catch (RuntimeException e) { ex.add(ode); ex.add(e); } } private void updateMonitorInformation(InitialLdapContext ctx, List<Exception> ex) private void updateMonitorInformation(ConnectionWrapper connWrapper, List<Exception> ex) { // Read monitoring information: since it is computed, it is faster // to get everything in just one request. SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); ctls.setReturningAttributes(getMonitoringAttributes()); String filter = "(objectclass=*)"; SearchRequest request = newSearchRequest("cn=monitor", WHOLE_SUBTREE, "(objectclass=*)", getMonitoringAttributes()); try try (ConnectionEntryReader monitorEntries = connWrapper.getConnection().search(request)) { LdapName jndiName = new LdapName("cn=monitor"); NamingEnumeration<SearchResult> monitorEntries = ctx.search(jndiName, filter, ctls); javaVersion = null; numberConnections = -1; try while (monitorEntries.hasNext()) { while (monitorEntries.hasMore()) { SearchResult sr = monitorEntries.next(); handleMonitoringSearchResult(sr, "cn=monitor"); handleMonitoringSearchResult(monitorEntries.readEntry()); } } finally catch (IOException e) { monitorEntries.close(); } } catch (NamingException ne) { ex.add(new OnlineUpdateException(ERR_READING_CONFIG_LDAP.get(ne.getMessage()), ne)); ex.add(new OnlineUpdateException(ERR_READING_CONFIG_LDAP.get(e.getMessage()), e)); } } @@ -912,7 +888,7 @@ * Updates the provided list of TaskEntry with the task entries found in a * server. * * @param ctx * @param connWrapper * the connection to the server. * @param ex * the list of exceptions encountered while retrieving the task @@ -920,35 +896,23 @@ * @param ts * the list of task entries to be updated. */ public void updateTaskInformation(InitialLdapContext ctx, List<Exception> ex, Collection<TaskEntry> ts) public void updateTaskInformation(ConnectionWrapper connWrapper, List<Exception> ex, Collection<TaskEntry> ts) { // Read monitoring information: since it is computed, it is faster // to get everything in just one request. SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.SUBTREE_SCOPE); ctls.setReturningAttributes(getMonitoringAttributes()); String filter = "(objectclass=ds-task)"; try SearchRequest request = newSearchRequest(DN_TASK_ROOT, WHOLE_SUBTREE, "(objectclass=ds-task)", getMonitoringAttributes()); try (ConnectionEntryReader taskEntries = connWrapper.getConnection().search(request)) { LdapName jndiName = new LdapName(ConfigConstants.DN_TASK_ROOT); NamingEnumeration<SearchResult> taskEntries = ctx.search(jndiName, filter, ctls); try while (taskEntries.hasNext()) { while (taskEntries.hasMore()) { SearchResult sr = taskEntries.next(); handleTaskSearchResult(sr, ConfigConstants.DN_TASK_ROOT, ts, ex); SearchResultEntry sr = taskEntries.readEntry(); handleTaskSearchResult(sr, ts, ex); } } finally catch (IOException e) { taskEntries.close(); } } catch (NamingException ne) { ex.add(new OnlineUpdateException(ERR_READING_CONFIG_LDAP.get(ne.getMessage()), ne)); ex.add(new OnlineUpdateException(ERR_READING_CONFIG_LDAP.get(e.getMessage()), e)); } } @@ -1024,7 +988,7 @@ protocol = ConnectionHandlerDescriptor.Protocol.OTHER; port = -1; } Set<CustomSearchResult> emptySet = Collections.emptySet(); Set<SearchResultEntry> emptySet = Collections.emptySet(); return new ConnectionHandlerDescriptor(addresses, port, protocol, state, name, emptySet); } @@ -1047,51 +1011,51 @@ addAll(addresses, adminConnector.getListenAddress()); int port = adminConnector.getListenPort(); Set<CustomSearchResult> emptySet = Collections.emptySet(); Set<SearchResultEntry> emptySet = Collections.emptySet(); return new ConnectionHandlerDescriptor( addresses, port, protocol, state, INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString(), emptySet); } private boolean isRootMonitor(CustomSearchResult csr) throws OpenDsException private boolean isRootMonitor(SearchResultEntry sr) throws OpenDsException { return monitorDN.equals(DN.valueOf(csr.getDN())); return monitorDN.equals(sr.getName()); } private boolean isVersionMonitor(CustomSearchResult csr) throws OpenDsException private boolean isVersionMonitor(SearchResultEntry sr) throws OpenDsException { return versionDN.equals(DN.valueOf(csr.getDN())); return versionDN.equals(sr.getName()); } private boolean isSystemInformation(CustomSearchResult csr) throws OpenDsException private boolean isSystemInformation(SearchResultEntry sr) throws OpenDsException { return systemInformationDN.equals(DN.valueOf(csr.getDN())); return systemInformationDN.equals(sr.getName()); } private boolean isJvmMemoryUsage(CustomSearchResult csr) throws OpenDsException private boolean isJvmMemoryUsage(SearchResultEntry sr) throws OpenDsException { return jvmMemoryUsageDN.equals(DN.valueOf(csr.getDN())); return jvmMemoryUsageDN.equals(sr.getName()); } private boolean isWorkQueue(CustomSearchResult csr) throws OpenDsException private boolean isWorkQueue(SearchResultEntry sr) throws OpenDsException { return workQueueDN.equals(DN.valueOf(csr.getDN())); return workQueueDN.equals(sr.getName()); } private boolean isEntryCaches(CustomSearchResult csr) throws OpenDsException private boolean isEntryCaches(SearchResultEntry sr) throws OpenDsException { return entryCachesDN.equals(DN.valueOf(csr.getDN())); return entryCachesDN.equals(sr.getName()); } private boolean isConnectionHandler(CustomSearchResult csr) throws OpenDsException private boolean isConnectionHandler(SearchResultEntry sr) throws OpenDsException { DN dn = DN.valueOf(csr.getDN()); DN dn = sr.getName(); DN parent = dn.parent(); if (parent != null && parent.equals(monitorDN)) { List<?> vs = csr.getAttributeValues("cn"); if (vs != null && !vs.isEmpty()) Set<String> vs = sr.getAttribute("cn").parse().asSetOfString(); if (!vs.isEmpty()) { String cn = (String) vs.iterator().next(); String cn = vs.iterator().next(); String statistics = " Statistics"; if (cn.endsWith(statistics)) { @@ -1102,19 +1066,15 @@ return false; } private static boolean isTaskEntry(CustomSearchResult csr) throws OpenDsException private static boolean isTaskEntry(SearchResultEntry sr) { List<Object> vs = csr.getAttributeValues("objectclass"); if (vs != null && !vs.isEmpty()) for (String oc : sr.getAttribute("objectclass").parse().asSetOfString()) { for (Object oc : vs) { if (oc.toString().equalsIgnoreCase("ds-task")) if (oc.equalsIgnoreCase("ds-task")) { return true; } } } return false; } @@ -1131,9 +1091,9 @@ return value.toLowerCase(); } private Set<CustomSearchResult>getMonitoringEntries(ConnectionHandlerDescriptor ch) private Set<SearchResultEntry> getMonitoringEntries(ConnectionHandlerDescriptor ch) { Set<CustomSearchResult> monitorEntries = new HashSet<>(); Set<SearchResultEntry> monitorEntries = new HashSet<>(); if (ch.getState() == ConnectionHandlerDescriptor.State.ENABLED) { for (String key : hmConnectionHandlersMonitor.keySet()) opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -32,15 +32,8 @@ import org.forgerock.i18n.LocalizableMessage; import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.config.server.ConfigException; import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; import org.opends.guitools.controlpanel.task.OfflineUpdateException; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.server.config.server.AdministrationConnectorCfg; import org.forgerock.opendj.server.config.server.BackendCfg; import org.forgerock.opendj.server.config.server.BackendIndexCfg; @@ -63,8 +56,15 @@ import org.forgerock.opendj.server.config.server.RootDNUserCfg; import org.forgerock.opendj.server.config.server.SNMPConnectionHandlerCfg; import org.forgerock.opendj.server.config.server.TaskBackendCfg; import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor; import org.opends.guitools.controlpanel.datamodel.BackendDescriptor; import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor; import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor; import org.opends.guitools.controlpanel.datamodel.IndexDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor; import org.opends.guitools.controlpanel.datamodel.VLVSortOrder; import org.opends.guitools.controlpanel.task.OfflineUpdateException; import org.opends.server.core.DirectoryServer; import org.forgerock.opendj.ldap.DN; import org.opends.server.types.OpenDsException; /** @@ -362,7 +362,7 @@ final ConnectionHandlerDescriptor.Protocol protocol = isReplicationSecure ? ConnectionHandlerDescriptor.Protocol.REPLICATION_SECURE : ConnectionHandlerDescriptor.Protocol.REPLICATION; final Set<CustomSearchResult> emptySet = Collections.emptySet(); final Set<SearchResultEntry> emptySet = Collections.emptySet(); final ConnectionHandlerDescriptor connHandler = new ConnectionHandlerDescriptor(new HashSet<InetAddress>(), replicationPort, protocol, ConnectionHandlerDescriptor.State.ENABLED, "Multimaster Synchronization", emptySet); @@ -498,7 +498,7 @@ protocol = ConnectionHandlerDescriptor.Protocol.OTHER; port = -1; } final Set<CustomSearchResult> emptySet = Collections.emptySet(); final Set<SearchResultEntry> emptySet = Collections.emptySet(); return new ConnectionHandlerDescriptor(addresses, port, protocol, state, name, emptySet); } @@ -520,7 +520,7 @@ addAll(addresses, adminConnector.getListenAddress()); final int port = adminConnector.getListenPort(); final Set<CustomSearchResult> emptySet = Collections.emptySet(); final Set<SearchResultEntry> emptySet = Collections.emptySet(); return new ConnectionHandlerDescriptor(addresses, port, protocol, state, INFO_CTRL_PANEL_CONN_HANDLER_ADMINISTRATION.get().toString(), emptySet); } opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
@@ -16,37 +16,41 @@ */ package org.opends.guitools.controlpanel.util; import static org.forgerock.opendj.ldap.SearchScope.*; import static org.forgerock.opendj.ldap.requests.Requests.*; import static org.forgerock.opendj.ldap.schema.CoreSchema.*; import static org.forgerock.opendj.ldap.schema.Schema.*; import static org.opends.server.config.ConfigConstants.*; import static org.opends.server.config.ConfigConstants.ATTR_ATTRIBUTE_TYPES; import static org.opends.server.config.ConfigConstants.ATTR_LDAP_SYNTAXES; import static org.opends.server.schema.SchemaConstants.*; import java.util.Arrays; import java.util.HashSet; import java.util.Set; import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import javax.naming.ldap.InitialLdapContext; import java.util.Iterator; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.ldap.ByteStringBuilder; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.Attribute; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.Filter; import org.forgerock.opendj.ldap.LdapException; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.forgerock.opendj.ldap.schema.MatchingRuleImpl; import org.forgerock.opendj.ldap.schema.SchemaBuilder; import org.opends.guitools.controlpanel.browser.BrowserController; import org.opends.guitools.controlpanel.datamodel.CustomSearchResult; import org.opends.admin.ads.util.ConnectionWrapper; import org.opends.server.api.AttributeSyntax; import org.opends.server.config.ConfigConstants; import org.opends.server.core.DirectoryServer; import org.opends.server.core.ServerContext; import org.opends.server.replication.plugin.HistoricalCsnOrderingMatchingRuleImpl; import org.opends.server.schema.AciSyntax; import org.opends.server.schema.SchemaConstants; import org.opends.server.schema.SubtreeSpecificationSyntax; import org.opends.server.types.DirectoryException; import org.opends.server.types.InitializationException; import org.opends.server.types.Schema; import org.opends.server.types.Schema.SchemaUpdater; /** Class used to retrieve the schema from the schema files. */ public class RemoteSchemaLoader extends SchemaLoader @@ -68,52 +72,42 @@ /** * Reads the schema. * * @param ctx * @param connWrapper * the connection to be used to load the schema. * @throws NamingException * @throws LdapException * if an error occurs reading the schema. * @throws DirectoryException * if an error occurs parsing the schema. * @throws InitializationException * if an error occurs finding the base schema. * @throws ConfigException * if an error occurs loading the configuration required to use the * schema classes. * if an error occurs loading the configuration required to use the schema classes. */ public void readSchema(InitialLdapContext ctx) throws NamingException, DirectoryException, InitializationException, ConfigException public void readSchema(ConnectionWrapper connWrapper) throws LdapException, DirectoryException, InitializationException, ConfigException { final String[] schemaAttrs = { ConfigConstants.ATTR_LDAP_SYNTAXES_LC, ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC, ConfigConstants.ATTR_OBJECTCLASSES_LC }; final SearchControls searchControls = new SearchControls(); searchControls.setSearchScope(SearchControls.OBJECT_SCOPE); searchControls.setReturningAttributes(schemaAttrs); final NamingEnumeration<SearchResult> srs = ctx.search( ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, BrowserController.ALL_OBJECTS_FILTER, searchControls); SearchResult sr = null; try { while (srs.hasMore()) { sr = srs.next(); } } finally { srs.close(); } final CustomSearchResult csr = new CustomSearchResult(sr, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT); schema = getBaseSchema(); // Add missing matching rules and attribute syntaxes to base schema to allow read of remote server schema // (see OPENDJ-1122 for more details) addMissingSyntaxesToBaseSchema(new AciSyntax(), new SubtreeSpecificationSyntax()); addMissingMatchingRuleToBaseSchema("1.3.6.1.4.1.26027.1.4.4", "historicalCsnOrderingMatch", "1.3.6.1.4.1.1466.115.121.1.40", new HistoricalCsnOrderingMatchingRuleImpl()); for (final String str : schemaAttrs) final SearchRequest request = newSearchRequest( DN.valueOf(DN_DEFAULT_SCHEMA_ROOT), BASE_OBJECT, Filter.alwaysTrue(), ATTR_LDAP_SYNTAXES, ATTR_ATTRIBUTE_TYPES, ATTR_OBJECTCLASSES); final SearchResultEntry entry = connWrapper.getConnection().searchSingleEntry(request); removeNonOpenDjOrOpenDsSyntaxes(entry); schema.updateSchema(new SchemaUpdater() { registerSchemaAttr(csr, str); @Override public org.forgerock.opendj.ldap.schema.Schema update(SchemaBuilder builder) { builder.addSchema(entry, true); return builder.toSchema(); } }); } private void addMissingSyntaxesToBaseSchema(final AttributeSyntax<?>... syntaxes) @@ -143,84 +137,34 @@ } else { matchingRule = new SchemaBuilder(schemaNG).buildMatchingRule(oid) matchingRule = new SchemaBuilder(schemaNG) .buildMatchingRule(oid) .names(name) .syntaxOID(syntaxOID) .implementation(impl) .addToSchema().toSchema().getMatchingRule(oid); .addToSchema() .toSchema() .getMatchingRule(oid); } schema.registerMatchingRules(Arrays.asList(matchingRule), true); } private void registerSchemaAttr(final CustomSearchResult csr, final String schemaAttr) throws DirectoryException private void removeNonOpenDjOrOpenDsSyntaxes(final SearchResultEntry entry) throws DirectoryException { final Set<Object> remainingAttrs = new HashSet<>(csr.getAttributeValues(schemaAttr)); if (schemaAttr.equals(ConfigConstants.ATTR_LDAP_SYNTAXES_LC)) Attribute attribute = entry.getAttribute(AttributeDescription.create(getLDAPSyntaxesAttributeType())); if (attribute != null) { registerSyntaxDefinitions(remainingAttrs); return; } while (!remainingAttrs.isEmpty()) for (Iterator<ByteString> it = attribute.iterator(); it.hasNext();) { DirectoryException lastException = null; final Set<Object> registered = new HashSet<>(); for (final Object definition : remainingAttrs) final String definition = it.next().toString(); if (!definition.contains(OID_OPENDS_SERVER_BASE) && !definition.contains(OID_OPENDJ_BASE)) { final String definitionStr = toString(definition); try { switch (schemaAttr) { case ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC: schema.registerAttributeType(definitionStr, null, true); break; case ConfigConstants.ATTR_OBJECTCLASSES_LC: schema.registerObjectClass(definitionStr, null, true); break; } registered.add(definition); } catch (DirectoryException de) { lastException = de; } } if (registered.isEmpty()) { throw lastException; } remainingAttrs.removeAll(registered); } } private void registerSyntaxDefinitions(Set<Object> definitions) throws DirectoryException { for (final Object definition : definitions) { final String definitionStr = toString(definition); if (definition.toString().contains(SchemaConstants.OID_OPENDS_SERVER_BASE)) { try { schema.registerSyntax(definitionStr, true); } catch (DirectoryException e) { // Filter error code to ignore exceptions raised on description syntaxes. if (e.getResultCode() != ResultCode.UNWILLING_TO_PERFORM) { throw e; it.remove(); } } } } } private String toString(final Object definition) { return new ByteStringBuilder().appendObject(definition).toString(); } /** * Returns the schema that was read. opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -19,6 +19,9 @@ import static com.forgerock.opendj.cli.Utils.*; import static com.forgerock.opendj.util.OperatingSystem.*; import static org.forgerock.opendj.ldap.DereferenceAliasesPolicy.*; import static org.forgerock.opendj.ldap.SearchScope.*; import static org.forgerock.opendj.ldap.requests.Requests.*; import static org.opends.admin.ads.util.ConnectionUtils.*; import static org.opends.admin.ads.util.PreferredConnection.Type.*; import static org.opends.messages.AdminToolMessages.*; @@ -45,6 +48,7 @@ import java.util.Collection; import java.util.Comparator; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.logging.Logger; import java.util.regex.Pattern; @@ -93,8 +97,12 @@ import org.forgerock.i18n.slf4j.LocalizedLogger; import org.forgerock.opendj.config.ConfigurationFramework; import org.forgerock.opendj.config.server.ConfigException; import org.forgerock.opendj.ldap.Attribute; import org.forgerock.opendj.ldap.AttributeDescription; import org.forgerock.opendj.ldap.ByteString; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.SearchResultEntry; import org.forgerock.opendj.ldap.schema.AttributeType; import org.forgerock.opendj.ldap.schema.MatchingRule; import org.forgerock.opendj.ldap.schema.Syntax; @@ -2266,12 +2274,34 @@ } /** * Ping the specified connection. This method sends a search request on the root entry of the DIT * and forward the corresponding exception (if any). * * @param connWrapper * the connection to be "pinged". * @throws NamingException * if the ping could not be performed. */ public static void ping(ConnectionWrapper connWrapper) throws NamingException { SearchRequest request = newSearchRequest("", BASE_OBJECT, "objectClass=*", "1.1") .setSizeLimit(0) .setTimeLimit(0) .setDereferenceAliasesPolicy(NEVER); connWrapper.getConnection().search(request); } /** * Deletes a configuration subtree using the provided configuration handler. * @param confHandler the configuration handler to be used to delete the * subtree. * @param dn the DN of the subtree to be deleted. * @throws OpenDsException if an error occurs. * @throws ConfigException if an error occurs. * * @param confHandler * the configuration handler to be used to delete the subtree. * @param dn * the DN of the subtree to be deleted. * @throws OpenDsException * if an error occurs. * @throws ConfigException * if an error occurs. */ public static void deleteConfigSubtree(ConfigurationHandler confHandler, DN dn) throws OpenDsException, ConfigException @@ -2392,29 +2422,26 @@ } } private static Object getFirstMonitoringValue(CustomSearchResult sr, String attrName) private static Object getFirstMonitoringValue(Attribute attribute) { if (sr != null) Iterator<ByteString> it = attribute.iterator(); if (it.hasNext()) { List<Object> values = sr.getAttributeValues(attrName); if (values != null && !values.isEmpty()) { Object o = values.iterator().next(); try { return Long.parseLong(o.toString()); return attribute.parse().asLong(); } catch (Throwable t1) { ByteString v = it.next(); try { return Double.parseDouble(o.toString()); return Double.parseDouble(v.toString()); } catch (Throwable t2) { // Cannot convert it, just return it return o; } return v; } } } @@ -2455,10 +2482,9 @@ * @param monitoringEntry the monitoring entry. * @return the monitoring value in a String form to be displayed to the user. */ public static String getMonitoringValue(MonitoringAttributes attr, CustomSearchResult monitoringEntry) public static String getMonitoringValue(MonitoringAttributes attr, SearchResultEntry monitoringEntry) { String monitoringValue = getFirstValueAsString(monitoringEntry, attr.getAttributeName()); String monitoringValue = monitoringEntry.getAttribute(attr.getAttributeName()).firstValueAsString(); if (monitoringValue == null) { return NO_VALUE_SET.toString(); @@ -2515,15 +2541,14 @@ * @return {@code true} if the provided monitoring value represents the non implemented label, * {@code false} otherwise. */ private static boolean isNotImplemented(MonitoringAttributes attr, CustomSearchResult monitoringEntry) private static boolean isNotImplemented(MonitoringAttributes attr, SearchResultEntry monitoringEntry) { String monitoringValue = getFirstValueAsString(monitoringEntry, attr.getAttributeName()); Attribute monitoringValue = monitoringEntry.getAttribute(attr.getAttributeName()); if (attr.isNumeric() && monitoringValue != null) { try { Long.parseLong(monitoringValue); monitoringValue.parse().asLong(); return false; } catch (Throwable t) @@ -2642,8 +2667,8 @@ * @param attrNames * the names for which to compute possible comparison results */ public static void computeMonitoringPossibleResults(CustomSearchResult monitor1, CustomSearchResult monitor2, ArrayList<Integer> possibleResults, Collection<String> attrNames) public static void computeMonitoringPossibleResults(SearchResultEntry monitor1, SearchResultEntry monitor2, List<Integer> possibleResults, Collection<String> attrNames) { for (String attrName : attrNames) { @@ -2665,8 +2690,8 @@ } else { Object v1 = getFirstValue(monitor1, attrName); Object v2 = getFirstValue(monitor2, attrName); Object v1 = getFirstMonitoringValue(monitor1.getAttribute(attrName)); Object v2 = getFirstMonitoringValue(monitor2.getAttribute(attrName)); if (v1 == null) { if (v2 == null) @@ -2739,18 +2764,6 @@ } } private static Object getFirstValue(CustomSearchResult monitor, String attrName) { for (String attr : monitor.getAttributeNames()) { if (attr.equalsIgnoreCase(attrName)) { return getFirstMonitoringValue(monitor, attrName); } } return null; } /** * Throw the first exception of the list (if any). * opendj-server-legacy/src/main/java/org/opends/server/schema/SchemaConstants.java
@@ -55,9 +55,9 @@ private static final String OID_OPENDS_BASE = "1.3.6.1.4.1.26027"; /** * The IANA-assigned base OID for all things under the OpenDS umbrella. * The IANA-assigned base OID for all things under the OpenDJ umbrella. */ private static final String OID_OPENDJ_BASE = "1.3.6.1.4.1.36733.2.1"; public static final String OID_OPENDJ_BASE = "1.3.6.1.4.1.36733.2.1"; /** opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -2015,7 +2015,7 @@ List<TaskEntry> taskEntries = new ArrayList<>(); List<Exception> exceptions = new ArrayList<>(); ConfigFromDirContext cfg = new ConfigFromDirContext(); cfg.updateTaskInformation(conn.getLdapContext(), exceptions, taskEntries); cfg.updateTaskInformation(conn, exceptions, taskEntries); for (Exception ode : exceptions) { logger.warn(LocalizableMessage.raw("Error retrieving task entries: "+ode, ode)); @@ -5839,8 +5839,8 @@ } } } String bindDn = getBindDN(conn.getLdapContext()); String pwd = getBindPassword(conn.getLdapContext()); String bindDn = conn.getBindDn().toString(); String pwd = conn.getBindPassword(); for (ServerDescriptor s : serversToUpdate) { removeReferencesInServer(s, replicationServerHostPort, bindDn, pwd, @@ -5850,11 +5850,10 @@ if (disableReplicationServer) { // Disable replication server disableReplicationServer(conn); replicationServerDisabled = true; // Wait to be sure that changes are taken into account and reset the // contents of the ADS. // Wait to be sure that changes are taken into account // and reset the contents of the ADS. sleepCatchInterrupt(5000); } } opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
@@ -399,45 +399,6 @@ } /** * Registers an attribute type from its provided definition. * * @param definition * The definition of the attribute type * @param schemaFile * The schema file where this definition belongs, * maybe {@code null} * @param overwrite * Indicates whether to overwrite the attribute * type if it already exists based on OID or name * @throws DirectoryException * If an error occurs */ public void registerAttributeType(final String definition, final String schemaFile, final boolean overwrite) throws DirectoryException { exclusiveLock.lock(); try { String defWithFile = getDefinitionWithSchemaFile(definition, schemaFile); switchSchema(new SchemaBuilder(schemaNG) .addAttributeType(defWithFile, overwrite) .toSchema()); } catch (ConflictingSchemaElementException | UnknownSchemaElementException e) { throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); } catch (LocalizedIllegalArgumentException e) { throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e); } finally { exclusiveLock.unlock(); } } /** * Registers the provided attribute type definition with this schema. * * @param attributeType @@ -755,44 +716,6 @@ } /** * Registers an object class from its provided definition. * * @param definition * The definition of the object class * @param schemaFile * The schema file where this definition belongs, may be {@code null} * @param overwriteExisting * Indicates whether to overwrite the object class * if it already exists based on OID or name * @throws DirectoryException * If an error occurs */ public void registerObjectClass(String definition, String schemaFile, boolean overwriteExisting) throws DirectoryException { exclusiveLock.lock(); try { String defWithFile = getDefinitionWithSchemaFile(definition, schemaFile); switchSchema(new SchemaBuilder(schemaNG) .addObjectClass(defWithFile, overwriteExisting) .toSchema()); } catch (ConflictingSchemaElementException | UnknownSchemaElementException e) { throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, e.getMessageObject(), e); } catch (LocalizedIllegalArgumentException e) { throw new DirectoryException(ResultCode.INVALID_ATTRIBUTE_SYNTAX, e.getMessageObject(), e); } finally { exclusiveLock.unlock(); } } /** * Deregisters the provided objectclass definition with this schema. * * @param objectClass The objectclass to deregister with this schema. @@ -1134,11 +1057,6 @@ } } private String getDefinitionWithSchemaFile(String definition, String schemaFile) { return schemaFile != null ? addSchemaFileToElementDefinitionIfAbsent(definition, schemaFile) : definition; } /** * Deregisters the provided matching rule use definition with this schema. *