Class DefaultSchemaLdifExtractor
- java.lang.Object
-
- org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor
-
- All Implemented Interfaces:
SchemaLdifExtractor
public class DefaultSchemaLdifExtractor extends Object implements SchemaLdifExtractor
Extracts LDIF files for the schema repository onto a destination directory.- Author:
- Apache Directory Project
-
-
Constructor Summary
Constructors Constructor Description DefaultSchemaLdifExtractor(File outputDirectory)
Creates an extractor which deposits files into the specified output directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.
-
-
-
Constructor Detail
-
DefaultSchemaLdifExtractor
public DefaultSchemaLdifExtractor(File outputDirectory)
Creates an extractor which deposits files into the specified output directory.- Parameters:
outputDirectory
- the directory where the schema root is extracted
-
-
Method Detail
-
isExtracted
public boolean isExtracted()
Gets whether or not schema folder has been created or not.- Specified by:
isExtracted
in interfaceSchemaLdifExtractor
- Returns:
- true if schema folder has already been extracted.
-
extractOrCopy
public void extractOrCopy(boolean overwrite) throws IOException
Extracts the LDIF files from a Jar file or copies exploded LDIF resources.- Specified by:
extractOrCopy
in interfaceSchemaLdifExtractor
- Parameters:
overwrite
- over write extracted structure if true, false otherwise- Throws:
IOException
- if schema already extracted and on IO errors
-
extractOrCopy
public void extractOrCopy() throws IOException
Extracts the LDIF files from a Jar file or copies exploded LDIF resources without overwriting the resources if the schema has already been extracted.- Specified by:
extractOrCopy
in interfaceSchemaLdifExtractor
- Throws:
IOException
- if schema already extracted and on IO errors
-
getUniqueResourceAsStream
public static InputStream getUniqueResourceAsStream(String resourceName, String resourceDescription) throws IOException
Gets the unique schema file resource from the class loader off the base path. If the same resource exists multiple times then an error will result since the resource is not unique.- Parameters:
resourceName
- the file name of the resource to loadresourceDescription
- human description of the resource- Returns:
- the InputStream to read the contents of the resource
- Throws:
IOException
- if there are problems reading or finding a unique copy of the resource
-
getUniqueResource
public static URL getUniqueResource(String resourceName, String resourceDescription) throws IOException
Gets a unique resource from the class loader.- Parameters:
resourceName
- the name of the resourceresourceDescription
- the description of the resource- Returns:
- the URL to the resource in the class loader
- Throws:
IOException
- if there is an IO error
-
getAnyResource
public static URL getAnyResource(String resourceName, String resourceDescription) throws IOException
Gets resource from the class loader. In case of several files with the same name, it returns any of them. This is useful in cases when the same artefacts are loaded several times, e.g. in some testing scenarios.- Parameters:
resourceName
- the name of the resourceresourceDescription
- the description of the resource- Returns:
- the URL to the resource in the class loader
- Throws:
IOException
- if there is an IO error
-
-