| | |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | | import java.net.InetAddress; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | */ |
| | | public void readConfiguration(InitialLdapContext ctx) |
| | | { |
| | | exceptions.clear(); |
| | | List<OpenDsException> ex = new ArrayList<OpenDsException>(); |
| | | Set<ConnectionHandlerDescriptor> ls = |
| | | new HashSet<ConnectionHandlerDescriptor>(); |
| | | Set<BackendDescriptor> bs = new HashSet<BackendDescriptor>(); |
| | | Set<DN> as = new HashSet<DN>(); |
| | | |
| | | try |
| | | { |
| | |
| | | JNDIDirContextAdaptor.adapt(ctx)); |
| | | RootCfgClient root = mCtx.getRootConfiguration(); |
| | | |
| | | listeners.clear(); |
| | | try |
| | | { |
| | | AdministrationConnectorCfgClient adminConnector = |
| | |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | String[] connectionHandlers = root.listConnectionHandlers(); |
| | | for (int i=0; i<connectionHandlers.length; i++) |
| | |
| | | { |
| | | ConnectionHandlerCfgClient connectionHandler = |
| | | root.getConnectionHandler(connectionHandlers[i]); |
| | | listeners.add(getConnectionHandler(connectionHandler, |
| | | ls.add(getConnectionHandler(connectionHandler, |
| | | connectionHandlers[i])); |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | isSchemaEnabled = root.getGlobalConfiguration().isCheckSchema(); |
| | | |
| | | backends.clear(); |
| | | String[] backendNames = root.listBackends(); |
| | | for (int i=0; i<backendNames.length; i++) |
| | | { |
| | |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | indexes.add( |
| | | new IndexDescriptor("dn2id", null, null, |
| | |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | else if (backend instanceof LDIFBackendCfgClient) |
| | |
| | | { |
| | | baseDN.setBackend(desc); |
| | | } |
| | | backends.add(desc); |
| | | bs.add(desc); |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | |
| | | |
| | |
| | | protocol, |
| | | ConnectionHandlerDescriptor.State.ENABLED, |
| | | "Multimaster Synchronization"); |
| | | listeners.add(connHandler); |
| | | ls.add(connHandler); |
| | | } |
| | | } |
| | | String[] domains = sync.listReplicationDomains(); |
| | |
| | | ReplicationDomainCfgClient domain = |
| | | sync.getReplicationDomain(domains[i]); |
| | | DN dn = domain.getBaseDN(); |
| | | for (BackendDescriptor backend : backends) |
| | | for (BackendDescriptor backend : bs) |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | RootDNCfgClient rootDN = root.getRootDN(); |
| | | String[] rootUsers = rootDN.listRootDNUsers(); |
| | | administrativeUsers.clear(); |
| | | if (rootUsers != null) |
| | | { |
| | | for (int i=0; i < rootUsers.length; i++) |
| | | { |
| | | RootDNUserCfgClient rootUser = rootDN.getRootDNUser(rootUsers[i]); |
| | | administrativeUsers.addAll(rootUser.getAlternateBindDN()); |
| | | as.addAll(rootUser.getAlternateBindDN()); |
| | | } |
| | | } |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | |
| | | updateMonitorInformation(ctx); |
| | | updateMonitorInformation(ctx, bs, ex); |
| | | |
| | | try |
| | | { |
| | |
| | | } |
| | | catch (OpenDsException oe) |
| | | { |
| | | exceptions.add(oe); |
| | | ex.add(oe); |
| | | } |
| | | } |
| | | catch (final Throwable t) |
| | | { |
| | | OnlineUpdateException ex = new OnlineUpdateException( |
| | | OnlineUpdateException oupe = new OnlineUpdateException( |
| | | ERR_READING_CONFIG_LDAP.get(t.toString()), t); |
| | | exceptions.add(ex); |
| | | ex.add(oupe); |
| | | } |
| | | for (OpenDsException oe : ex) |
| | | { |
| | | LOG.log(Level.WARNING, "Error reading configuration: "+oe, oe); |
| | | } |
| | | exceptions = Collections.unmodifiableList(ex); |
| | | administrativeUsers = Collections.unmodifiableSet(as); |
| | | listeners = Collections.unmodifiableSet(ls); |
| | | backends = Collections.unmodifiableSet(bs); |
| | | } |
| | | |
| | | private void updateMonitorInformation(InitialLdapContext ctx) |
| | | private void updateMonitorInformation(InitialLdapContext ctx, |
| | | Set<BackendDescriptor> bs, |
| | | List<OpenDsException> ex) |
| | | { |
| | | // Read monitoring information: since it is computed, it is faster |
| | | // to get everything in just one request. |
| | |
| | | |
| | | if ((dn != null) && (replicaId != null)) |
| | | { |
| | | for (BackendDescriptor backend : backends) |
| | | for (BackendDescriptor backend : bs) |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | |
| | | if ((backendID != null) && ((entryCount != null) || |
| | | (baseDnEntries != null))) |
| | | { |
| | | for (BackendDescriptor backend : backends) |
| | | for (BackendDescriptor backend : bs) |
| | | { |
| | | if (backend.getBackendID().equalsIgnoreCase(backendID)) |
| | | { |
| | |
| | | } |
| | | catch (NamingException ne) |
| | | { |
| | | OnlineUpdateException ex = new OnlineUpdateException( |
| | | OnlineUpdateException oue = new OnlineUpdateException( |
| | | ERR_READING_CONFIG_LDAP.get(ne.getMessage().toString()), ne); |
| | | exceptions.add(ex); |
| | | } |
| | | |
| | | |
| | | for (OpenDsException oe : exceptions) |
| | | { |
| | | LOG.log(Level.WARNING, "Error reading configuration: "+oe, oe); |
| | | ex.add(oue); |
| | | } |
| | | } |
| | | |