public class DefaultSchemaLdifExtractor extends java.lang.Object implements SchemaLdifExtractor
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
BASE_PATH
The base path.
|
private static java.util.regex.Pattern |
EXTRACT_PATTERN
The pattern to extract the schema from LDIF files.
|
private boolean |
extracted
The extracted flag.
|
private static org.slf4j.Logger |
LOG
The logger.
|
private java.io.File |
outputDirectory
The output directory.
|
private static java.lang.String |
SCHEMA_SUBDIR
The schema sub-directory.
|
| Constructor and Description |
|---|
DefaultSchemaLdifExtractor(java.io.File outputDirectory)
Creates an extractor which deposits files into the specified output
directory.
|
| Modifier and Type | Method and Description |
|---|---|
private java.io.File |
assembleDestinationFile(java.util.Stack<java.lang.String> fileComponentStack)
Assembles the destination file by appending file components previously
pushed on the fileComponentStack argument.
|
private void |
copyFile(java.io.File source,
java.io.File destination)
Copies a file line by line from the source file argument to the
destination file argument.
|
private void |
extractFromClassLoader(java.lang.String resource)
Extracts the LDIF schema resource from class loader.
|
void |
extractOrCopy()
Extracts the LDIF files from a Jar file or copies exploded LDIF
resources without overwriting the resources if the schema has
already been extracted.
|
void |
extractOrCopy(boolean overwrite)
Extracts the LDIF files from a Jar file or copies exploded LDIF resources.
|
private java.io.File |
getDestinationFile(java.io.File resource)
Calculates the destination file.
|
static java.net.URL |
getUniqueResource(java.lang.String resourceName,
java.lang.String resourceDescription)
Gets a unique resource from the class loader.
|
static java.io.InputStream |
getUniqueResourceAsStream(java.lang.String resourceName,
java.lang.String resourceDescription)
Gets the unique schema file resource from the class loader off the base path.
|
boolean |
isExtracted()
Gets whether or not schema folder has been created or not.
|
private static final java.lang.String BASE_PATH
private static final java.lang.String SCHEMA_SUBDIR
private static final org.slf4j.Logger LOG
private static final java.util.regex.Pattern EXTRACT_PATTERN
private boolean extracted
private java.io.File outputDirectory
public DefaultSchemaLdifExtractor(java.io.File outputDirectory)
outputDirectory - the directory where the schema root is extractedpublic boolean isExtracted()
isExtracted in interface SchemaLdifExtractorpublic void extractOrCopy(boolean overwrite)
throws java.io.IOException
extractOrCopy in interface SchemaLdifExtractoroverwrite - over write extracted structure if true, false otherwisejava.io.IOException - if schema already extracted and on IO errorspublic void extractOrCopy()
throws java.io.IOException
extractOrCopy in interface SchemaLdifExtractorjava.io.IOException - if schema already extracted and on IO errorsprivate void copyFile(java.io.File source,
java.io.File destination)
throws java.io.IOException
source - the source file to copydestination - the destination to copy the source tojava.io.IOException - if there are IO errors or the source does not existprivate java.io.File assembleDestinationFile(java.util.Stack<java.lang.String> fileComponentStack)
fileComponentStack - stack containing pushed file componentsprivate java.io.File getDestinationFile(java.io.File resource)
resource - the source filepublic static java.io.InputStream getUniqueResourceAsStream(java.lang.String resourceName,
java.lang.String resourceDescription)
throws java.io.IOException
resourceName - the file name of the resource to loadresourceDescription - human description of the resourcejava.io.IOException - if there are problems reading or finding a unique copy of the resourcepublic static java.net.URL getUniqueResource(java.lang.String resourceName,
java.lang.String resourceDescription)
throws java.io.IOException
resourceName - the name of the resourceresourceDescription - the description of the resourcejava.io.IOException - if there is an IO errorprivate void extractFromClassLoader(java.lang.String resource)
throws java.io.IOException
resource - the LDIF schema resourcejava.io.IOException - if there are IO errors