public class ConfigWriter
extends java.lang.Object
It can be used either:
| Modifier and Type | Field and Description |
|---|---|
private ConfigBean |
configBean
The configuration bean
|
private java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> |
entries
The list of entries
|
private org.apache.directory.api.ldap.model.schema.SchemaManager |
schemaManager
The schema manager
|
| Constructor and Description |
|---|
ConfigWriter(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
ConfigBean configBean)
Creates a new instance of ConfigWriter.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
addAttributeTypeValue(java.lang.String attributeType,
java.lang.Object value,
org.apache.directory.api.ldap.model.ldif.LdifEntry entry)
Adds a value, either byte[] or another type (converted into a String
via the Object.toString() method), to the attribute.
|
private void |
addAttributeTypeValues(java.lang.String attributeType,
java.lang.Object o,
org.apache.directory.api.ldap.model.ldif.LdifEntry entry)
Adds values for an attribute type to the given entry.
|
private void |
addBean(org.apache.directory.api.ldap.model.name.Dn rootDn,
org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
AdsBaseBean bean,
java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> entries)
Adds a configuration bean to the list of entries.
|
private void |
addBean(org.apache.directory.api.ldap.model.name.Dn rootDn,
org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
AdsBaseBean bean,
java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> entries,
org.apache.directory.api.ldap.model.ldif.LdifEntry parentEntry,
java.lang.String attributeTypeForParentEntry)
Adds a configuration bean to the list of entries.
|
private void |
addObjectClassAttribute(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
org.apache.directory.api.ldap.model.ldif.LdifEntry entry,
java.lang.String objectClass)
Adds the computed 'objectClass' attribute for the given entry and object class name.
|
private void |
computeObjectClassAttributeValues(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
java.util.Set<java.lang.String> objectClassAttributeValues,
org.apache.directory.api.ldap.model.schema.ObjectClass objectClass)
Recursively computes the 'objectClass' attribute values set.
|
private void |
convertConfigurationBeanToLdifEntries()
Converts the configuration bean to a list of LDIF entries.
|
private java.lang.String |
getClassNameWithoutPackageName(java.lang.Class<?> c)
Gets the class name of the given class stripped from its package name.
|
java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> |
getConvertedLdifEntries()
Gets the converted LDIF entries from the configuration bean.
|
private org.apache.directory.api.ldap.model.name.Dn |
getDn(org.apache.directory.api.ldap.model.name.Dn baseDn,
AdsBaseBean bean)
Gets the Dn associated with the configuration bean based on the given base Dn.
|
private java.lang.String |
getObjectClassNameForBean(java.lang.Class<?> c)
Gets the name of the object class to use for the given bean class.
|
private boolean |
isMultiple(java.lang.Class<?> clazz)
Indicates the given type is multiple.
|
void |
writeToFile(java.io.File file)
Writes the configuration bean as LDIF to the given file.
|
void |
writeToPath(java.lang.String path)
Writes the configuration bean as LDIF to the given file.
|
java.lang.String |
writeToString()
Writes the configuration to a String object.
|
private org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager
private ConfigBean configBean
private java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> entries
public ConfigWriter(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
ConfigBean configBean)
schemaManager - the schema managerconfigBean - the configuration beanprivate void convertConfigurationBeanToLdifEntries()
throws ConfigurationException
ConfigurationExceptionpublic void writeToPath(java.lang.String path)
throws ConfigurationException,
java.io.IOException
path - the output file pathConfigurationException - if an error occurs during the conversion to LDIFjava.io.IOException - if an error occurs when writing the filepublic void writeToFile(java.io.File file)
throws ConfigurationException,
java.io.IOException
file - the output fileConfigurationException - if an error occurs during the conversion to LDIFjava.io.IOException - if an error occurs when writing the filepublic java.lang.String writeToString()
throws ConfigurationException
ConfigurationException - if an error occurs during the conversion to LDIFpublic java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> getConvertedLdifEntries()
throws ConfigurationException
ConfigurationException - if an error occurs during the conversion to LDIFprivate void addObjectClassAttribute(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
org.apache.directory.api.ldap.model.ldif.LdifEntry entry,
java.lang.String objectClass)
throws org.apache.directory.api.ldap.model.exception.LdapException
schemaManager - the schema managerentry - the entryobjectClass - the object class nameorg.apache.directory.api.ldap.model.exception.LdapExceptionprivate void computeObjectClassAttributeValues(org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
java.util.Set<java.lang.String> objectClassAttributeValues,
org.apache.directory.api.ldap.model.schema.ObjectClass objectClass)
throws org.apache.directory.api.ldap.model.exception.LdapException
schemaManager - the schema managerobjectClassAttributeValues - the set containing the valuesobjectClass - the current object classorg.apache.directory.api.ldap.model.exception.LdapExceptionprivate void addBean(org.apache.directory.api.ldap.model.name.Dn rootDn,
org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
AdsBaseBean bean,
java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> entries)
throws java.lang.Exception
rootDn - the current root DnschemaManager - the schema managerbean - the configuration beanentries - the list of the entriesjava.lang.Exceptionprivate void addBean(org.apache.directory.api.ldap.model.name.Dn rootDn,
org.apache.directory.api.ldap.model.schema.SchemaManager schemaManager,
AdsBaseBean bean,
java.util.List<org.apache.directory.api.ldap.model.ldif.LdifEntry> entries,
org.apache.directory.api.ldap.model.ldif.LdifEntry parentEntry,
java.lang.String attributeTypeForParentEntry)
throws java.lang.Exception
rootDn - the current root DnschemaManager - the schema managerbean - the configuration beanentries - the list of the entriesparentEntry - the parent entryattributeTypeForParentEntry - the attribute type to use when adding the value of
the Rdn to the parent entryjava.lang.Exceptionprivate java.lang.String getObjectClassNameForBean(java.lang.Class<?> c)
c - the bean classprivate java.lang.String getClassNameWithoutPackageName(java.lang.Class<?> c)
c - the classprivate boolean isMultiple(java.lang.Class<?> clazz)
clazz - the classtrue if the given is multiple,
false if not.private org.apache.directory.api.ldap.model.name.Dn getDn(org.apache.directory.api.ldap.model.name.Dn baseDn,
AdsBaseBean bean)
throws org.apache.directory.api.ldap.model.exception.LdapInvalidDnException,
java.lang.IllegalArgumentException,
java.lang.IllegalAccessException
baseDn - the base Dnbean - the configuration beanorg.apache.directory.api.ldap.model.exception.LdapInvalidDnExceptionjava.lang.IllegalArgumentExceptionjava.lang.IllegalAccessExceptionprivate void addAttributeTypeValues(java.lang.String attributeType,
java.lang.Object o,
org.apache.directory.api.ldap.model.ldif.LdifEntry entry)
throws org.apache.directory.api.ldap.model.exception.LdapException
attributeType - the attribute typevalue - the valueentry - the entryorg.apache.directory.api.ldap.model.exception.LdapExceptionprivate void addAttributeTypeValue(java.lang.String attributeType,
java.lang.Object value,
org.apache.directory.api.ldap.model.ldif.LdifEntry entry)
throws org.apache.directory.api.ldap.model.exception.LdapException
attributeType - the attribute typevalue - the valueentry - the entryorg.apache.directory.api.ldap.model.exception.LdapException