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

Jean-Noel Rouvignac
29.32.2013 545ec8fb9616742de4e9ec7e98222fb7e55001d9
LDIFExportConfig.java:
Code cleanup.
Converted comments to javadocs.
Collapsed useless if statement.
1 files modified
106 ■■■■ changed files
opends/src/server/org/opends/server/types/LDIFExportConfig.java 106 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/types/LDIFExportConfig.java
@@ -26,6 +26,7 @@
 *      Portions Copyright 2013 ForgeRock AS.
 */
package org.opends.server.types;
import static org.opends.messages.UtilityMessages.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.StaticUtils.*;
@@ -40,8 +41,6 @@
import org.opends.messages.Message;
import org.opends.server.loggers.debug.DebugTracer;
/**
 * This class defines a data structure for holding configuration
 * information to use when performing an LDIF export.
@@ -59,75 +58,84 @@
   */
  private static final DebugTracer TRACER = getTracer();
  // Indicates whether the data should be compressed as it is written.
  /** Indicates whether the data should be compressed as it is written. */
  private boolean compressData;
  // Indicates whether the data should be encrypted as it is written.
  /** Indicates whether the data should be encrypted as it is written. */
  private boolean encryptData;
  // Indicates whether we should exclude operational attributes.
  private boolean excludeOperationalAttributes;
  // Indicates whether to generate a cryptographic hash of the data as
  // it is // written.
  /**
   * Indicates whether to generate a cryptographic hash of the data as it is
   * written.
   */
  private boolean hashData;
  // Indicates whether to include the objectclasses in the entries
  // written in the export.
  /**
   * Indicates whether to include the objectclasses in the entries written in
   * the export.
   */
  private boolean includeObjectClasses;
  // Indicates whether to include operational attributes in the
  // export.
  /**
   * Indicates whether to include operational attributes in the export.
   */
  private boolean includeOperationalAttributes;
  // Indicates whether to include virutal attributes in the export.
  /** Indicates whether to include virtual attributes in the export. */
  private boolean includeVirtualAttributes;
  // Indicates whether to invoke LDIF export plugins on entries being
  // exported.
  /**
   * Indicates whether to invoke LDIF export plugins on entries being exported.
   */
  private boolean invokeExportPlugins;
  // Indicates whether to digitally sign the hash when the export is
  // complete.
  /**
   * Indicates whether to digitally sign the hash when the export is complete.
   */
  private boolean signHash;
  // Indicates whether to include attribute types (i.e., names) only
  // or both types and values.
  /**
   * Indicates whether to include attribute types (i.e., names) only or both
   * types and values.
   */
  private boolean typesOnly;
  // The buffered writer to which the LDIF data should be written.
  /** The buffered writer to which the LDIF data should be written. */
  private BufferedWriter writer;
  // The behavior that should be used when writing an LDIF file and a
  // file with the same name already exists.
  /**
   * The behavior that should be used when writing an LDIF file and a file with
   * the same name already exists.
   */
  private ExistingFileBehavior existingFileBehavior;
  // The column number at which long lines should be wrapped.
  /** The column number at which long lines should be wrapped. */
  private int wrapColumn;
  // The set of base DNs to exclude from the export.
  /** The set of base DNs to exclude from the export. */
  private List<DN> excludeBranches;
  // The set of base DNs to include from the export.
  /** The set of base DNs to include from the export. */
  private List<DN> includeBranches;
  // The set of search filters for entries to exclude from the export.
  /** The set of search filters for entries to exclude from the export. */
  private List<SearchFilter> excludeFilters;
  // The set of search filters for entries to include in the export.
  /** The set of search filters for entries to include in the export. */
  private List<SearchFilter> includeFilters;
  // The output stream to which the LDIF data should be written.
  /** The output stream to which the LDIF data should be written. */
  private OutputStream ldifOutputStream;
  // The set of attribute types that should be excluded from the
  // export.
  /**
   * The set of attribute types that should be excluded from the export.
   */
  private Set<AttributeType> excludeAttributes;
  // The set of attribute types that should be included in the export.
  /** The set of attribute types that should be included in the export. */
  private Set<AttributeType> includeAttributes;
  // The path to the LDIF file that should be written.
  /** The path to the LDIF file that should be written. */
  private String ldifFile;
@@ -154,7 +162,6 @@
    includeFilters               = new ArrayList<SearchFilter>();
    compressData                 = false;
    encryptData                  = false;
    excludeOperationalAttributes = false;
    hashData                     = false;
    includeObjectClasses         = true;
    includeOperationalAttributes = true;
@@ -254,8 +261,7 @@
          }
          else
          {
            // Create new file ensuring that we can set its
            // permissions.
            // Create new file ensuring that we can set its permissions.
            f.createNewFile();
            mustSetPermissions = true;
            ldifOutputStream = new FileOutputStream(ldifFile);
@@ -273,8 +279,7 @@
          }
          catch (Exception e)
          {
            // The file could not be created with the correct
            // permissions.
            // The file could not be created with the correct permissions.
            Message message =
              WARN_EXPORT_LDIF_SET_PERMISSION_FAILED.get(f.toString(),
                    stackTraceToSingleLineString(e));
@@ -304,8 +309,7 @@
      // Create the writer.
      writer =
           new BufferedWriter(new OutputStreamWriter(outputStream));
      writer = new BufferedWriter(new OutputStreamWriter(outputStream));
    }
    return writer;
@@ -633,8 +637,7 @@
   *                                should be included in the
   *                                export.
   */
  public void setIncludeObjectClasses(
                   boolean includeObjectClasses)
  public void setIncludeObjectClasses(boolean includeObjectClasses)
  {
    this.includeObjectClasses = includeObjectClasses;
  }
@@ -747,8 +750,7 @@
   *                            included in the entries written to
   *                            LDIF.
   */
  public void setIncludeAttributes(
                   Set<AttributeType> includeAttributes)
  public void setIncludeAttributes(Set<AttributeType> includeAttributes)
  {
    if (includeAttributes == null)
    {
@@ -775,14 +777,10 @@
   */
  public boolean includeAttribute(AttributeType attributeType)
  {
    if ((! excludeAttributes.isEmpty()) &&
        excludeAttributes.contains(attributeType))
    {
      return false;
    }
    return includeAttributes.isEmpty() ||
        includeAttributes.contains(attributeType);
    return (excludeAttributes.isEmpty()
              || !excludeAttributes.contains(attributeType))
        && (includeAttributes.isEmpty()
              || includeAttributes.contains(attributeType));
  }
@@ -935,10 +933,10 @@
  /**
   * Closes any resources that this export config might have open.
   */
  @Override
  public void close()
  {
    // FIXME -- Need to add code to generate a signed hash of the LDIF
    //          content.
    // FIXME -- Need to add code to generate a signed hash of the LDIF content.
    if (writer != null) {
      try