org.opends.server.types
Class LDIFImportConfig

java.lang.Object
  extended by org.opends.server.types.OperationConfig
      extended by org.opends.server.types.LDIFImportConfig

@PublicAPI(stability=VOLATILE,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class LDIFImportConfig
extends OperationConfig

This class defines a data structure for holding configuration information to use when performing an LDIF import.


Constructor Summary
LDIFImportConfig(java.io.InputStream ldifInputStream)
          Creates a new LDIF import configuration that will read from the provided input stream.
LDIFImportConfig(java.util.List<java.lang.String> ldifFiles)
          Creates a new LDIF import configuration that will read from the specified LDIF files.
LDIFImportConfig(java.io.Reader ldifInputReader)
          Creates a new LDIF import configuration that will read from the provided reader.
LDIFImportConfig(java.lang.String ldifFile)
          Creates a new LDIF import configuration that will read from the specified LDIF file.
LDIFImportConfig(TemplateFile templateFile)
          Creates a new LDIF import configuration that will generate entries using the given MakeLDIF template file rather than reading them from an existing LDIF file.
 
Method Summary
 boolean appendToExistingData()
          Indicates whether to append to an existing data set or completely replace it.
 boolean clearBackend()
          Indicates whether to clear the entire backend if importing to a backend with more than one base DNs.
 void close()
          Closes any resources that this import config might have open.
 int getBufferSize()
          Retrieves the buffer size that should be used when reading LDIF data.
 java.util.Set<AttributeType> getExcludeAttributes()
          Retrieves the set of attributes that should be excluded from the entries read from the LDIF.
 java.util.List<DN> getExcludeBranches()
          Retrieves the set of base DNs that specify the set of entries to exclude from the import.
 java.util.List<SearchFilter> getExcludeFilters()
          Retrieves the set of search filters that should be used to determine which entries to exclude from the LDIF.
 java.util.Set<AttributeType> getIncludeAttributes()
          Retrieves the set of attributes that should be included in the entries read from the LDIF.
 java.util.List<DN> getIncludeBranches()
          Retrieves the set of base DNs that specify the set of entries to include in the import.
 java.util.List<SearchFilter> getIncludeFilters()
          Retrieves the set of search filters that should be used to determine which entries to include in the LDIF.
 java.io.BufferedReader getReader()
          Retrieves the reader that should be used to read the LDIF data.
 java.io.BufferedWriter getRejectWriter()
          Retrieves the writer that should be used to write entries that are rejected rather than imported for some reason.
 java.io.BufferedWriter getSkipWriter()
          Retrieves the writer that should be used to write entries that are skipped because they don't match the criteri.
 boolean includeAttribute(AttributeType attributeType)
          Indicates whether the specified attribute should be included in the entries read from the LDIF.
 boolean includeEntry(DN dn)
          Indicates whether to include the entry with the specified DN in the import.
 boolean includeEntry(Entry entry)
          Indicates whether the specified entry should be included in the import based on the configured set of include and exclude filters.
 boolean includeObjectClasses()
          Indicates whether the set of objectclasses should be included in the entries read from the LDIF.
 boolean invokeImportPlugins()
          Indicates whether any LDIF import plugins registered with the server should be invoked during the import operation.
 boolean isCompressed()
          Indicates whether the input LDIF source is expected to be compressed.
 boolean isEncrypted()
          Indicates whether the input LDIF source is expected to be encrypted.
 java.io.BufferedReader nextReader()
          Retrieves the LDIF reader configured to read from the next LDIF file in the list.
 boolean replaceExistingEntries()
          Indicates whether to replace the existing entry if a duplicate is found or to reject the new entry.
 void setAppendToExistingData(boolean appendToExistingData)
          Specifies whether to append to an existing data set or completely replace it.
 void setBufferSize(int bufferSize)
          Specifies the buffer size that should be used when reading LDIF data.
 void setClearBackend(boolean clearBackend)
          Specifies whether to clear the entire backend if importing to a backend.
 void setCompressed(boolean isCompressed)
          Specifies whether the input LDIF source is expected to be compressed.
 void setEncrypted(boolean isEncrypted)
          Specifies whether the input LDIF source is expected to be encrypted.
 void setExcludeAllOperationalAttributes(boolean excludeAllOpAttrs)
          Specifies whether all the operational attributes should be excluded.
 void setExcludeAllUserAttributes(boolean excludeAllUserAttrs)
          Specifies whether all the user attributes should be excluded.
 void setExcludeAttributes(java.util.Set<AttributeType> excludeAttributes)
          Specifies the set of attributes that should be excluded from the entries read from the LDIF.
 void setExcludeBranches(java.util.List<DN> excludeBranches)
          Specifies the set of base DNs that specify the set of entries to exclude from the import.
 void setExcludeFilters(java.util.List<SearchFilter> excludeFilters)
          Specifies the set of search filters that should be used to determine which entries to exclude from the LDIF.
 void setIncludeAllOpAttributes(boolean includeAllOpAttrs)
          Specifies whether all the operational attributes should be included.
 void setIncludeAllUserAttributes(boolean includeAllUserAttrs)
          Specifies whether all the user attributes should be included.
 void setIncludeAttributes(java.util.Set<AttributeType> includeAttributes)
          Specifies the set of attributes that should be included in the entries read from the LDIF.
 void setIncludeBranches(java.util.List<DN> includeBranches)
          Specifies the set of base DNs that specify the set of entries to include in the import.
 void setIncludeFilters(java.util.List<SearchFilter> includeFilters)
          Specifies the set of search filters that should be used to determine which entries to include in the LDIF.
 void setIncludeObjectClasses(boolean includeObjectClasses)
          Specifies whether the set of objectclasses should be included in the entries read from the LDIF.
 void setInvokeImportPlugins(boolean invokeImportPlugins)
          Specifies whether any LDIF import plugins registered with the server should be invoked during the import operation.
 void setReplaceExistingEntries(boolean replaceExistingEntries)
          Specifies whether to replace the existing entry if a duplicate is found or to reject the new entry.
 void setValidateSchema(boolean validateSchema)
          Specifies whether to perform schema validation on entries as they are read.
 boolean validateSchema()
          Indicates whether to perform schema validation on entries as they are read.
 void writeRejectedEntries(java.io.OutputStream outputStream)
          Indicates that rejected entries should be written to the provided output stream.
 void writeRejectedEntries(java.lang.String rejectFile, ExistingFileBehavior existingFileBehavior)
          Indicates that rejected entries should be written to the specified file.
 void writeSkippedEntries(java.io.OutputStream outputStream)
          Indicates that skipped entries should be written to the provided output stream.
 void writeSkippedEntries(java.lang.String skipFile, ExistingFileBehavior existingFileBehavior)
          Indicates that skipped entries should be written to the specified file.
 
Methods inherited from class org.opends.server.types.OperationConfig
cancel, isCancelled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LDIFImportConfig

public LDIFImportConfig(java.lang.String ldifFile)
Creates a new LDIF import configuration that will read from the specified LDIF file.

Parameters:
ldifFile - The path to the LDIF file with the data to import.

LDIFImportConfig

public LDIFImportConfig(java.util.List<java.lang.String> ldifFiles)
Creates a new LDIF import configuration that will read from the specified LDIF files. The files will be imported in the order they are specified in the provided list.

Parameters:
ldifFiles - The paths to the LDIF files with the data to import.

LDIFImportConfig

public LDIFImportConfig(java.io.InputStream ldifInputStream)
Creates a new LDIF import configuration that will read from the provided input stream.

Parameters:
ldifInputStream - The input stream from which to read the LDIF data.

LDIFImportConfig

public LDIFImportConfig(java.io.Reader ldifInputReader)
Creates a new LDIF import configuration that will read from the provided reader.

Parameters:
ldifInputReader - The input stream from which to read the LDIF data.

LDIFImportConfig

public LDIFImportConfig(TemplateFile templateFile)
Creates a new LDIF import configuration that will generate entries using the given MakeLDIF template file rather than reading them from an existing LDIF file.

Parameters:
templateFile - The template file to use to generate the entries.
Method Detail

getReader

public java.io.BufferedReader getReader()
                                 throws java.io.IOException
Retrieves the reader that should be used to read the LDIF data. Note that if the LDIF file is compressed and/or encrypted, then that must be indicated before this method is called for the first time.

Returns:
The reader that should be used to read the LDIF data.
Throws:
java.io.IOException - If a problem occurs while obtaining the reader.

nextReader

public java.io.BufferedReader nextReader()
                                  throws java.io.IOException
Retrieves the LDIF reader configured to read from the next LDIF file in the list.

Returns:
The reader that should be used to read the LDIF data, or null if there are no more files to read.
Throws:
java.io.IOException - If a problem occurs while obtaining the reader.

getRejectWriter

public java.io.BufferedWriter getRejectWriter()
Retrieves the writer that should be used to write entries that are rejected rather than imported for some reason.

Returns:
The reject writer, or null if none is to be used.

getSkipWriter

public java.io.BufferedWriter getSkipWriter()
Retrieves the writer that should be used to write entries that are skipped because they don't match the criteri.

Returns:
The skip writer, or null if none is to be used.

writeRejectedEntries

public void writeRejectedEntries(java.lang.String rejectFile,
                                 ExistingFileBehavior existingFileBehavior)
                          throws java.io.IOException
Indicates that rejected entries should be written to the specified file. Note that this applies only to entries that are rejected because they are invalid (e.g., are malformed or don't conform to schema requirements), and not to entries that are rejected because they matched exclude criteria.

Parameters:
rejectFile - The path to the file to which reject information should be written.
existingFileBehavior - Indicates how to treat an existing file.
Throws:
java.io.IOException - If a problem occurs while opening the reject file for writing.

writeRejectedEntries

public void writeRejectedEntries(java.io.OutputStream outputStream)
Indicates that rejected entries should be written to the provided output stream. Note that this applies only to entries that are rejected because they are invalid (e.g., are malformed or don't conform to schema requirements), and not to entries that are rejected because they matched exclude criteria.

Parameters:
outputStream - The output stream to which rejected entries should be written.

writeSkippedEntries

public void writeSkippedEntries(java.lang.String skipFile,
                                ExistingFileBehavior existingFileBehavior)
                         throws java.io.IOException
Indicates that skipped entries should be written to the specified file. Note that this applies only to entries that are skipped because they matched exclude criteria.

Parameters:
skipFile - The path to the file to which skipped information should be written.
existingFileBehavior - Indicates how to treat an existing file.
Throws:
java.io.IOException - If a problem occurs while opening the skip file for writing.

writeSkippedEntries

public void writeSkippedEntries(java.io.OutputStream outputStream)
Indicates that skipped entries should be written to the provided output stream. Note that this does not apply to entries that are rejected because they are invalid (e.g., are malformed or don't conform to schema requirements), but only apply to entries that are skipped because they matched exclude criteria.

Parameters:
outputStream - The output stream to which skipped entries should be written.

appendToExistingData

public boolean appendToExistingData()
Indicates whether to append to an existing data set or completely replace it.

Returns:
true if the import should append to an existing data set, or false if not.

setAppendToExistingData

public void setAppendToExistingData(boolean appendToExistingData)
Specifies whether to append to an existing data set or completely replace it.

Parameters:
appendToExistingData - Indicates whether to append to an existing data set or completely replace it.

replaceExistingEntries

public boolean replaceExistingEntries()
Indicates whether to replace the existing entry if a duplicate is found or to reject the new entry. This only applies when appending to an existing data set.

Returns:
true if an existing entry should be replaced with the new entry from the provided data set, or false if the new entry should be rejected.

setReplaceExistingEntries

public void setReplaceExistingEntries(boolean replaceExistingEntries)
Specifies whether to replace the existing entry if a duplicate is found or to reject the new entry. This only applies when appending to an existing data set.

Parameters:
replaceExistingEntries - Indicates whether to replace the existing entry if a duplicate is found or to reject the new entry.

invokeImportPlugins

public boolean invokeImportPlugins()
Indicates whether any LDIF import plugins registered with the server should be invoked during the import operation.

Returns:
true if registered LDIF import plugins should be invoked during the import operation, or false if they should not be invoked.

setInvokeImportPlugins

public void setInvokeImportPlugins(boolean invokeImportPlugins)
Specifies whether any LDIF import plugins registered with the server should be invoked during the import operation.

Parameters:
invokeImportPlugins - Specifies whether any LDIF import plugins registered with the server should be invoked during the import operation.

isCompressed

public boolean isCompressed()
Indicates whether the input LDIF source is expected to be compressed.

Returns:
true if the LDIF source is expected to be compressed, or false if not.

setCompressed

public void setCompressed(boolean isCompressed)
Specifies whether the input LDIF source is expected to be compressed. If compression is used, then this must be set prior to the initial call to getReader.

Parameters:
isCompressed - Indicates whether the input LDIF source is expected to be compressed.

isEncrypted

public boolean isEncrypted()
Indicates whether the input LDIF source is expected to be encrypted.

Returns:
true if the LDIF source is expected to be encrypted, or false if not.

setEncrypted

public void setEncrypted(boolean isEncrypted)
Specifies whether the input LDIF source is expected to be encrypted. If encryption is used, then this must be set prior to the initial call to getReader.

Parameters:
isEncrypted - Indicates whether the input LDIF source is expected to be encrypted.

clearBackend

public boolean clearBackend()
Indicates whether to clear the entire backend if importing to a backend with more than one base DNs.

Returns:
true if the entire backend should be cleared or false if not.

setClearBackend

public void setClearBackend(boolean clearBackend)
Specifies whether to clear the entire backend if importing to a backend.

Parameters:
clearBackend - Indicates whether to clear the entire backend.

validateSchema

public boolean validateSchema()
Indicates whether to perform schema validation on entries as they are read.

Returns:
true if schema validation should be performed on the entries as they are read, or false if not.

setValidateSchema

public void setValidateSchema(boolean validateSchema)
Specifies whether to perform schema validation on entries as they are read.

Parameters:
validateSchema - Indicates whether to perform schema validation on entries as they are read.

getExcludeBranches

public java.util.List<DN> getExcludeBranches()
Retrieves the set of base DNs that specify the set of entries to exclude from the import. The contents of the returned list may be altered by the caller.

Returns:
The set of base DNs that specify the set of entries to exclude from the import.

setExcludeBranches

public void setExcludeBranches(java.util.List<DN> excludeBranches)
Specifies the set of base DNs that specify the set of entries to exclude from the import.

Parameters:
excludeBranches - The set of base DNs that specify the set of entries to exclude from the import.

getIncludeBranches

public java.util.List<DN> getIncludeBranches()
Retrieves the set of base DNs that specify the set of entries to include in the import. The contents of the returned list may be altered by the caller.

Returns:
The set of base DNs that specify the set of entries to include in the import.

setIncludeBranches

public void setIncludeBranches(java.util.List<DN> includeBranches)
Specifies the set of base DNs that specify the set of entries to include in the import.

Parameters:
includeBranches - The set of base DNs that specify the set of entries to include in the import.

includeEntry

public boolean includeEntry(DN dn)
Indicates whether to include the entry with the specified DN in the import.

Parameters:
dn - The DN of the entry for which to make the determination.
Returns:
true if the entry with the specified DN should be included in the import, or false if not.

includeObjectClasses

public boolean includeObjectClasses()
Indicates whether the set of objectclasses should be included in the entries read from the LDIF.

Returns:
true if the set of objectclasses should be included in the entries read from the LDIF, or false if not.

setIncludeObjectClasses

public void setIncludeObjectClasses(boolean includeObjectClasses)
Specifies whether the set of objectclasses should be included in the entries read from the LDIF.

Parameters:
includeObjectClasses - Indicates whether the set of objectclasses should be included in the entries read from the LDIF.

getExcludeAttributes

public java.util.Set<AttributeType> getExcludeAttributes()
Retrieves the set of attributes that should be excluded from the entries read from the LDIF. The contents of the returned set may be modified by the caller.

Returns:
The set of attributes that should be excluded from the entries read from the LDIF.

setExcludeAttributes

public void setExcludeAttributes(java.util.Set<AttributeType> excludeAttributes)
Specifies the set of attributes that should be excluded from the entries read from the LDIF.

Parameters:
excludeAttributes - The set of attributes that should be excluded from the entries read from the LDIF.

getIncludeAttributes

public java.util.Set<AttributeType> getIncludeAttributes()
Retrieves the set of attributes that should be included in the entries read from the LDIF. The contents of the returned set may be modified by the caller.

Returns:
The set of attributes that should be included in the entries read from the LDIF.

setIncludeAttributes

public void setIncludeAttributes(java.util.Set<AttributeType> includeAttributes)
Specifies the set of attributes that should be included in the entries read from the LDIF.

Parameters:
includeAttributes - The set of attributes that should be included in the entries read from the LDIF.

includeAttribute

public boolean includeAttribute(AttributeType attributeType)
Indicates whether the specified attribute should be included in the entries read from the LDIF.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the specified attribute should be included in the entries read from the LDIF, or false if not.

getExcludeFilters

public java.util.List<SearchFilter> getExcludeFilters()
Retrieves the set of search filters that should be used to determine which entries to exclude from the LDIF. The contents of the returned list may be modified by the caller.

Returns:
The set of search filters that should be used to determine which entries to exclude from the LDIF.

setExcludeFilters

public void setExcludeFilters(java.util.List<SearchFilter> excludeFilters)
Specifies the set of search filters that should be used to determine which entries to exclude from the LDIF.

Parameters:
excludeFilters - The set of search filters that should be used to determine which entries to exclude from the LDIF.

getIncludeFilters

public java.util.List<SearchFilter> getIncludeFilters()
Retrieves the set of search filters that should be used to determine which entries to include in the LDIF. The contents of the returned list may be modified by the caller.

Returns:
The set of search filters that should be used to determine which entries to include in the LDIF.

setIncludeFilters

public void setIncludeFilters(java.util.List<SearchFilter> includeFilters)
Specifies the set of search filters that should be used to determine which entries to include in the LDIF.

Parameters:
includeFilters - The set of search filters that should be used to determine which entries to include in the LDIF.

includeEntry

public boolean includeEntry(Entry entry)
                     throws DirectoryException
Indicates whether the specified entry should be included in the import based on the configured set of include and exclude filters.

Parameters:
entry - The entry for which to make the determination.
Returns:
true if the specified entry should be included in the import, or false if not.
Throws:
DirectoryException - If there is a problem with any of the search filters used to make the determination.

getBufferSize

public int getBufferSize()
Retrieves the buffer size that should be used when reading LDIF data.

Returns:
The buffer size that should be used when reading LDIF data.

setBufferSize

public void setBufferSize(int bufferSize)
Specifies the buffer size that should be used when reading LDIF data.

Parameters:
bufferSize - The buffer size that should be used when reading LDIF data.

setExcludeAllUserAttributes

public void setExcludeAllUserAttributes(boolean excludeAllUserAttrs)
Specifies whether all the user attributes should be excluded.

Parameters:
excludeAllUserAttrs - Specifies all user attributes to be excluded.

setExcludeAllOperationalAttributes

public void setExcludeAllOperationalAttributes(boolean excludeAllOpAttrs)
Specifies whether all the operational attributes should be excluded.

Parameters:
excludeAllOpAttrs - Specifies whether all the operational attributes should be excluded.

setIncludeAllOpAttributes

public void setIncludeAllOpAttributes(boolean includeAllOpAttrs)
Specifies whether all the operational attributes should be included.

Parameters:
includeAllOpAttrs - Specifies whether all the operation attributes should be included.

setIncludeAllUserAttributes

public void setIncludeAllUserAttributes(boolean includeAllUserAttrs)
Specifies whether all the user attributes should be included.

Parameters:
includeAllUserAttrs - Specifies whether all the user attributes should be included.

close

public void close()
Closes any resources that this import config might have open.