public class DefaultSchemaLdifExtractor extends Object implements SchemaLdifExtractor
| Modifier and Type | Field and Description |
|---|---|
private static String |
BASE_PATH
The base path.
|
private static 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 File |
outputDirectory
The output directory.
|
private static String |
SCHEMA_SUBDIR
The schema sub-directory.
|
| Constructor and Description |
|---|
DefaultSchemaLdifExtractor(File outputDirectory)
Creates an extractor which deposits files into the specified output
directory.
|
| Modifier and Type | Method and Description |
|---|---|
private File |
assembleDestinationFile(Deque<String> fileComponentStack)
Assembles the destination file by appending file components previously
pushed on the fileComponentStack argument.
|
private void |
copyFile(File source,
File destination)
Copies a file line by line from the source file argument to the
destination file argument.
|
private void |
extractFromClassLoader(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.
|
static URL |
getAnyResource(String resourceName,
String resourceDescription)
Gets resource from the class loader.
|
private File |
getDestinationFile(File resource)
Calculates the destination file.
|
static URL |
getUniqueResource(String resourceName,
String resourceDescription)
Gets a unique resource from the class loader.
|
static InputStream |
getUniqueResourceAsStream(String resourceName,
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 String BASE_PATH
private static final String SCHEMA_SUBDIR
private static final org.slf4j.Logger LOG
private static final Pattern EXTRACT_PATTERN
private boolean extracted
private File outputDirectory
public DefaultSchemaLdifExtractor(File outputDirectory)
outputDirectory - the directory where the schema root is extractedpublic boolean isExtracted()
isExtracted in interface SchemaLdifExtractorpublic void extractOrCopy(boolean overwrite)
throws IOException
extractOrCopy in interface SchemaLdifExtractoroverwrite - over write extracted structure if true, false otherwiseIOException - if schema already extracted and on IO errorspublic void extractOrCopy()
throws IOException
extractOrCopy in interface SchemaLdifExtractorIOException - if schema already extracted and on IO errorsprivate void copyFile(File source, File destination) throws IOException
source - the source file to copydestination - the destination to copy the source toIOException - if there are IO errors or the source does not existprivate File assembleDestinationFile(Deque<String> fileComponentStack)
fileComponentStack - stack containing pushed file componentsprivate File getDestinationFile(File resource)
resource - the source filepublic static InputStream getUniqueResourceAsStream(String resourceName, String resourceDescription) throws IOException
resourceName - the file name of the resource to loadresourceDescription - human description of the resourceIOException - if there are problems reading or finding a unique copy of the resourcepublic static URL getUniqueResource(String resourceName, String resourceDescription) throws IOException
resourceName - the name of the resourceresourceDescription - the description of the resourceIOException - if there is an IO errorpublic static URL getAnyResource(String resourceName, String resourceDescription) throws IOException
resourceName - the name of the resourceresourceDescription - the description of the resourceIOException - if there is an IO errorprivate void extractFromClassLoader(String resource) throws IOException
resource - the LDIF schema resourceIOException - if there are IO errorsCopyright © 2003–2023 The Apache Software Foundation. All rights reserved.