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

Jean-Noël Rouvignac
23.02.2016 ed8da8f6a5f83b4322bc4fb86fcb9adbb02c8d88
code cleanup in backends
3 files modified
83 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java 64 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java 15 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/MonitorBackend.java
@@ -132,30 +132,9 @@
    final ArrayList<Attribute> userAttrs = new ArrayList<>();
    try
    {
      final Entry configEntry = DirectoryServer
          .getConfigEntry(configEntryDN);
      for (final List<Attribute> attrs : configEntry
          .getUserAttributes().values())
      {
        for (final Attribute a : attrs)
        {
          if (!isMonitorConfigAttribute(a))
          {
            userAttrs.add(a);
          }
        }
      }
      for (final List<Attribute> attrs : configEntry
          .getOperationalAttributes().values())
      {
        for (final Attribute a : attrs)
        {
          if (!isMonitorConfigAttribute(a))
          {
            userAttrs.add(a);
          }
        }
      }
      final Entry configEntry = DirectoryServer.getConfigEntry(configEntryDN);
      addAllNonMonitorConfigAttributes(userAttrs, configEntry.getUserAttributes().values());
      addAllNonMonitorConfigAttributes(userAttrs, configEntry.getOperationalAttributes().values());
    }
    catch (final Exception e)
    {
@@ -174,7 +153,20 @@
    return ccr;
  }
  /** {@inheritDoc} */
  private void addAllNonMonitorConfigAttributes(final List<Attribute> userAttrs, Collection<List<Attribute>> attrbutes)
  {
    for (final List<Attribute> attrs : attrbutes)
    {
      for (final Attribute a : attrs)
      {
        if (!isMonitorConfigAttribute(a))
        {
          userAttrs.add(a);
        }
      }
    }
  }
  @Override
  public void configureBackend(final MonitorBackendCfg config, ServerContext serverContext)
      throws ConfigException
@@ -232,16 +224,7 @@
  private void addAll(ArrayList<Attribute> attributes, Collection<List<Attribute>> attributesToAdd)
  {
    for (final List<Attribute> attrs : attributesToAdd)
    {
      for (final Attribute a : attrs)
      {
        if (!isMonitorConfigAttribute(a))
        {
          attributes.add(a);
        }
      }
    }
    addAllNonMonitorConfigAttributes(attributes, attributesToAdd);
  }
  /** {@inheritDoc} */
@@ -840,11 +823,10 @@
  {
    final AttributeType attrType = attribute.getAttributeDescription().getAttributeType();
    return attrType.hasName(ATTR_COMMON_NAME)
        || attrType.hasName(ATTR_BACKEND_ENABLED.toLowerCase())
        || attrType.hasName(ATTR_BACKEND_CLASS.toLowerCase())
        || attrType.hasName(ATTR_BACKEND_BASE_DN.toLowerCase())
        || attrType.hasName(ATTR_BACKEND_ID.toLowerCase())
        || attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE.toLowerCase());
        || attrType.hasName(ATTR_BACKEND_ENABLED)
        || attrType.hasName(ATTR_BACKEND_CLASS)
        || attrType.hasName(ATTR_BACKEND_BASE_DN)
        || attrType.hasName(ATTR_BACKEND_ID)
        || attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE);
  }
}
opendj-server-legacy/src/main/java/org/opends/server/backends/RootDSEBackend.java
@@ -284,8 +284,8 @@
  private boolean isDSEConfigAttribute(Attribute attribute)
  {
    AttributeType attrType = attribute.getAttributeDescription().getAttributeType();
    return attrType.hasName(ATTR_ROOT_DSE_SUBORDINATE_BASE_DN.toLowerCase())
        || attrType.hasName(ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES.toLowerCase())
    return attrType.hasName(ATTR_ROOT_DSE_SUBORDINATE_BASE_DN)
        || attrType.hasName(ATTR_ROOTDSE_SHOW_ALL_ATTRIBUTES)
        || attrType.hasName(ATTR_COMMON_NAME);
  }
opendj-server-legacy/src/main/java/org/opends/server/backends/SchemaBackend.java
@@ -456,19 +456,18 @@
  private boolean isSchemaConfigAttribute(Attribute attribute)
  {
    AttributeType attrType = attribute.getAttributeDescription().getAttributeType();
    return attrType.hasName(ATTR_SCHEMA_ENTRY_DN.toLowerCase()) ||
        attrType.hasName(ATTR_BACKEND_ENABLED.toLowerCase()) ||
        attrType.hasName(ATTR_BACKEND_CLASS.toLowerCase()) ||
        attrType.hasName(ATTR_BACKEND_ID.toLowerCase()) ||
        attrType.hasName(ATTR_BACKEND_BASE_DN.toLowerCase()) ||
        attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE.toLowerCase()) ||
        attrType.hasName(ATTR_SCHEMA_SHOW_ALL_ATTRIBUTES.toLowerCase()) ||
    return attrType.hasName(ATTR_SCHEMA_ENTRY_DN) ||
        attrType.hasName(ATTR_BACKEND_ENABLED) ||
        attrType.hasName(ATTR_BACKEND_CLASS) ||
        attrType.hasName(ATTR_BACKEND_ID) ||
        attrType.hasName(ATTR_BACKEND_BASE_DN) ||
        attrType.hasName(ATTR_BACKEND_WRITABILITY_MODE) ||
        attrType.hasName(ATTR_SCHEMA_SHOW_ALL_ATTRIBUTES) ||
        attrType.hasName(ATTR_COMMON_NAME) ||
        attrType.hasName(OP_ATTR_CREATORS_NAME_LC) ||
        attrType.hasName(OP_ATTR_CREATE_TIMESTAMP_LC) ||
        attrType.hasName(OP_ATTR_MODIFIERS_NAME_LC) ||
        attrType.hasName(OP_ATTR_MODIFY_TIMESTAMP_LC);
  }
  @Override