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

Violette Roche-Montane
28.47.2013 5449bec72778bd774c917843783c024243f079ec
Trivial style fix
2 files modified
138 ■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java 52 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java 86 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
@@ -23,6 +23,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.guitools.controlpanel.util;
@@ -52,7 +53,6 @@
/**
 * Class used to retrieve the schema from the schema files.
 *
 */
public class RemoteSchemaLoader extends SchemaLoader
{
@@ -60,7 +60,6 @@
  /**
   * Constructor.
   *
   */
  public RemoteSchemaLoader()
  {
@@ -69,30 +68,32 @@
  /**
   * Reads the schema.
   * @param ctx the connection to be used to load the schema.
   * @throws NamingException 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.
   *
   * @param ctx
   *          the connection to be used to load the schema.
   * @throws NamingException
   *           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.
   */
  public void readSchema(InitialLdapContext ctx) throws NamingException,
  DirectoryException, InitializationException, ConfigException
      DirectoryException, InitializationException, ConfigException
  {
    SearchControls searchControls = new SearchControls();
    searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
    String[] schemaAttrs =
    {
        ConfigConstants.ATTR_OBJECTCLASSES_LC,
        ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC
    };
        { ConfigConstants.ATTR_OBJECTCLASSES_LC,
          ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC };
    searchControls.setReturningAttributes(schemaAttrs);
    String filter = BrowserController.ALL_OBJECTS_FILTER;
    NamingEnumeration<SearchResult> srs =
      ctx.search(ConfigConstants.DN_DEFAULT_SCHEMA_ROOT,
          filter,
          searchControls);
        ctx.search(ConfigConstants.DN_DEFAULT_SCHEMA_ROOT, filter,
            searchControls);
    SearchResult sr = null;
    try
    {
@@ -105,17 +106,17 @@
    {
      srs.close();
    }
    CustomSearchResult csr = new CustomSearchResult(sr,
        ConfigConstants.DN_DEFAULT_SCHEMA_ROOT);
    CustomSearchResult csr =
        new CustomSearchResult(sr, ConfigConstants.DN_DEFAULT_SCHEMA_ROOT);
    schema = getBaseSchema();
    List<Object> attrs =
      csr.getAttributeValues(ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC);
        csr.getAttributeValues(ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC);
    Set<String> remainingAttrs = new HashSet<String>();
    for (Object o : attrs)
    {
      remainingAttrs.add((String)o);
      remainingAttrs.add((String) o);
    }
    while (!remainingAttrs.isEmpty())
@@ -130,7 +131,7 @@
        try
        {
          AttributeType attrType =
            AttributeTypeSyntax.decodeAttributeType(sb, schema, false);
              AttributeTypeSyntax.decodeAttributeType(sb, schema, false);
          schema.registerAttributeType(attrType, true);
          oneRegistered = true;
          registeredAttrs.add(attrDefinition);
@@ -148,12 +149,12 @@
    }
    List<Object> objectClasses =
      csr.getAttributeValues(ConfigConstants.ATTR_OBJECTCLASSES_LC);
        csr.getAttributeValues(ConfigConstants.ATTR_OBJECTCLASSES_LC);
    Set<String> remainingOcs = new HashSet<String>();
    for (Object o : objectClasses)
    {
      remainingOcs.add((String)o);
      remainingOcs.add((String) o);
    }
    while (!remainingOcs.isEmpty())
@@ -168,7 +169,7 @@
        try
        {
          ObjectClass oc =
            ObjectClassSyntax.decodeObjectClass(sb, schema, false);
              ObjectClassSyntax.decodeObjectClass(sb, schema, false);
          schema.registerObjectClass(oc, true);
          oneRegistered = true;
          registeredOcs.add(ocDefinition);
@@ -188,6 +189,7 @@
  /**
   * Returns the schema that was read.
   *
   * @return the schema that was read.
   */
  @Override
opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -51,32 +51,30 @@
/**
 * Class used to retrieve the schema from the schema files.
 *
 */
public class SchemaLoader
{
  private Schema schema;
  private final String[] attrsToKeep = {
      ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC,
      ConfigConstants.ATTR_OBJECTCLASSES_LC,
      ConfigConstants.ATTR_NAME_FORMS_LC,
      ConfigConstants.ATTR_DIT_CONTENT_RULES_LC,
      ConfigConstants.ATTR_DIT_STRUCTURE_RULES_LC,
      ConfigConstants.ATTR_MATCHING_RULE_USE_LC};
  private final String[] ocsToKeep = {"top"};
    ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC,
    ConfigConstants.ATTR_OBJECTCLASSES_LC,
    ConfigConstants.ATTR_NAME_FORMS_LC,
    ConfigConstants.ATTR_DIT_CONTENT_RULES_LC,
    ConfigConstants.ATTR_DIT_STRUCTURE_RULES_LC,
    ConfigConstants.ATTR_MATCHING_RULE_USE_LC };
  private final String[] ocsToKeep = { "top" };
  private final ArrayList<ObjectClass> objectclassesToKeep =
    new ArrayList<ObjectClass>();
      new ArrayList<ObjectClass>();
  private final ArrayList<AttributeType> attributesToKeep =
    new ArrayList<AttributeType>();
      new ArrayList<AttributeType>();
  private final ArrayList<MatchingRule> matchingRulesToKeep =
    new ArrayList<MatchingRule>();
      new ArrayList<MatchingRule>();
  private final ArrayList<AttributeSyntax<?>> syntaxesToKeep =
    new ArrayList<AttributeSyntax<?>>();
      new ArrayList<AttributeSyntax<?>>();
  /**
   * Constructor.
   *
   */
  public SchemaLoader()
  {
@@ -110,42 +108,47 @@
  private static String getSchemaDirectoryPath()
  {
    File schemaDir =
      DirectoryServer.getEnvironmentConfig().getSchemaDirectory();
    if (schemaDir != null) {
        DirectoryServer.getEnvironmentConfig().getSchemaDirectory();
    if (schemaDir != null)
    {
      return schemaDir.getAbsolutePath();
    } else {
    }
    else
    {
      return null;
    }
  }
  /**
   * Reads the schema.
   * @throws ConfigException if an error occurs reading the schema.
   * @throws InitializationException if an error occurs trying to find out
   * the schema files.
   * @throws DirectoryException if there is an error registering the minimal
   * objectclasses.
   *
   * @throws ConfigException
   *           if an error occurs reading the schema.
   * @throws InitializationException
   *           if an error occurs trying to find out the schema files.
   * @throws DirectoryException
   *           if there is an error registering the minimal objectclasses.
   */
  public void readSchema() throws DirectoryException,
  ConfigException, InitializationException
  public void readSchema() throws DirectoryException, ConfigException,
      InitializationException
  {
    schema = getBaseSchema();
    String[] fileNames;
    String schemaDirPath= getSchemaDirectoryPath();
    String schemaDirPath = getSchemaDirectoryPath();
    try
    {
      // Load install directory schema
      File schemaDir = new File(schemaDirPath);
      if (schemaDirPath == null || ! schemaDir.exists())
      if (schemaDirPath == null || !schemaDir.exists())
      {
        Message message = ERR_CONFIG_SCHEMA_NO_SCHEMA_DIR.get(schemaDirPath);
        throw new InitializationException(message);
      }
      else if (! schemaDir.isDirectory())
      else if (!schemaDir.isDirectory())
      {
        Message message =
          ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaDirPath);
            ERR_CONFIG_SCHEMA_DIR_NOT_DIRECTORY.get(schemaDirPath);
        throw new InitializationException(message);
      }
      FileFilter ldifFiles = new FileFilter()
@@ -161,11 +164,12 @@
            if (f.isDirectory())
            {
              accept = true;
            } else if (Utils.isWindows())
            }
            else if (Utils.isWindows())
            {
              accept =
                  f.getName().toLowerCase().endsWith(".ldif");
            } else
              accept = f.getName().toLowerCase().endsWith(".ldif");
            }
            else
            {
              accept = f.getName().endsWith(".ldif");
            }
@@ -195,14 +199,16 @@
    }
    catch (Exception e)
    {
      Message message = ERR_CONFIG_SCHEMA_CANNOT_LIST_FILES.get(
          schemaDirPath, e.getMessage());
      Message message =
          ERR_CONFIG_SCHEMA_CANNOT_LIST_FILES
              .get(schemaDirPath, e.getMessage());
      throw new InitializationException(message, e);
    }
//  Iterate through the schema files and read them as an LDIF file containing
//  a single entry.  Then get the attributeTypes and objectClasses attributes
//  from that entry and parse them to initialize the server schema.
    //  Iterate through the schema files and read them as an LDIF file
    //  containing a single entry.  Then get the attributeTypes and
    //  objectClasses attributes from that entry and parse them to
    //  initialize the server schema.
    for (String schemaFile : fileNames)
    {
      SchemaConfigManager.loadSchemaFile(schema, schemaFile);
@@ -210,11 +216,12 @@
  }
  /**
   * Returns a basic version of the schema.  The schema is created and contains
   * Returns a basic version of the schema. The schema is created and contains
   * enough definitions for the schema to be loaded.
   *
   * @return a basic version of the schema.
   * @throws DirectoryException if there is an error registering the minimal
   * objectclasses.
   * @throws DirectoryException
   *           if there is an error registering the minimal objectclasses.
   */
  protected Schema getBaseSchema() throws DirectoryException
  {
@@ -240,6 +247,7 @@
  /**
   * Returns the schema that was read.
   *
   * @return the schema that was read.
   */
  public Schema getSchema()