directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1043383 - /directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
Date Wed, 08 Dec 2010 12:25:29 GMT
Author: pamarcelot
Date: Wed Dec  8 12:25:29 2010
New Revision: 1043383

URL: http://svn.apache.org/viewvc?rev=1043383&view=rev
Log:
Add a new readConfig() method which implicitly uses "ou=config" as base DN.

Modified:
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1043383&r1=1043382&r2=1043383&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
Wed Dec  8 12:25:29 2010
@@ -56,6 +56,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
@@ -126,7 +127,7 @@ public class ConfigPartitionReader
     private ObjectClass findObjectClass( EntryAttribute objectClass ) throws Exception
     {
         Set<ObjectClass> candidates = new HashSet<ObjectClass>();
-        
+
         try
         {
             // Create the set of candidates
@@ -134,8 +135,8 @@ public class ConfigPartitionReader
             {
                 String ocName = ocValue.getString();
                 String ocOid = schemaManager.getObjectClassRegistry().getOidByName( ocName
);
-                ObjectClass oc = (ObjectClass)schemaManager.getObjectClassRegistry().get(
ocOid );
-                
+                ObjectClass oc = ( ObjectClass ) schemaManager.getObjectClassRegistry().get(
ocOid );
+
                 if ( oc.isStructural() )
                 {
                     candidates.add( oc );
@@ -147,14 +148,14 @@ public class ConfigPartitionReader
             e.printStackTrace();
             throw e;
         }
-        
+
         // Now find the parent OC
         for ( Value<?> ocValue : objectClass )
         {
             String ocName = ocValue.getString();
             String ocOid = schemaManager.getObjectClassRegistry().getOidByName( ocName );
-            ObjectClass oc = (ObjectClass)schemaManager.getObjectClassRegistry().get( ocOid
);
-            
+            ObjectClass oc = ( ObjectClass ) schemaManager.getObjectClassRegistry().get(
ocOid );
+
             for ( ObjectClass superior : oc.getSuperiors() )
             {
                 if ( oc.isStructural() )
@@ -166,15 +167,16 @@ public class ConfigPartitionReader
                 }
             }
         }
-        
+
         // The remaining OC in the candidates set is the one we are looking for
-        ObjectClass result = candidates.toArray( new ObjectClass[]{} )[0];
-        
+        ObjectClass result = candidates.toArray( new ObjectClass[]
+            {} )[0];
+
         LOG.debug( "The top level object class is {}", result.getName() );
         return result;
     }
-    
-    
+
+
     /** 
      * Create the base Bean from the ObjectClass name. 
      * The bean name is constructed using the OjectClass name, by
@@ -190,20 +192,20 @@ public class ConfigPartitionReader
         // Now, let's instanciate the associated bean. Get rid of the 'ads-' in front of
the name,
         // and uppercase the first letter. Finally add "Bean" at the end and add the package.
         //String beanName = this.getClass().getPackage().getName() + "org.apache.directory.server.config.beans."
+ Character.toUpperCase( objectClassName.charAt( 4 ) ) + objectClassName.substring( 5 ) +
"Bean";
-        String beanName = this.getClass().getPackage().getName() + ".beans." + 
-            Character.toUpperCase( objectClassName.charAt( ADS_PREFIX.length() ) ) + 
+        String beanName = this.getClass().getPackage().getName() + ".beans." +
+            Character.toUpperCase( objectClassName.charAt( ADS_PREFIX.length() ) ) +
             objectClassName.substring( ADS_PREFIX.length() + 1 ) + ADS_SUFFIX;
-        
+
         try
         {
             Class<?> clazz = Class.forName( beanName );
             Constructor<?> constructor = clazz.getConstructor();
-            AdsBaseBean bean = (AdsBaseBean)constructor.newInstance();
-            
+            AdsBaseBean bean = ( AdsBaseBean ) constructor.newInstance();
+
             LOG.debug( "Bean {} created for ObjectClass {}", beanName, objectClassName );
-            
+
             return bean;
-        } 
+        }
         catch ( ClassNotFoundException cnfe )
         {
             String message = "Cannot find a Bean class for the ObjectClass name " + objectClassName;
@@ -215,7 +217,7 @@ public class ConfigPartitionReader
             String message = "Cannot access to the class " + beanName;
             LOG.error( message );
             throw new ConfigurationException( message );
-        } 
+        }
         catch ( NoSuchMethodException nsme )
         {
             String message = "Cannot find a constructor for the class " + beanName;
@@ -241,53 +243,55 @@ public class ConfigPartitionReader
             throw new ConfigurationException( message );
         }
     }
-    
+
 
     /**
      * Retrieve the Field associated with an AttributeType name, if any.
      */
-    private static Field getField( Class<?> clazz, String attributeName, Class<?>
originalClazz ) throws ConfigurationException 
+    private static Field getField( Class<?> clazz, String attributeName, Class<?>
originalClazz )
+        throws ConfigurationException
     {
         // We will check all the fields, as the AT name is case insentitive
         // when the field is case sensitive
         Field[] fields = clazz.getDeclaredFields();
-        
+
         for ( Field field : fields )
         {
             String fieldName = field.getName();
-            
+
             if ( fieldName.equalsIgnoreCase( attributeName ) )
             {
                 return field;
             }
         }
-        
+
         // May be in the paren'ts class ?
         if ( clazz.getSuperclass() != null )
         {
             return getField( clazz.getSuperclass(), attributeName, originalClazz );
         }
-        
+
         String message = "Cannot find a field named " + attributeName + " in class " + originalClazz.getName();
         LOG.error( message );
         throw new ConfigurationException( message );
     }
-    
-    
+
+
     /**
      * Read the single entry value for an AttributeType, and feed the Bean field with this
value
      */
-    private void readSingleValueField( AdsBaseBean bean, Field beanField, EntryAttribute
fieldAttr, boolean mandatory ) throws ConfigurationException
+    private void readSingleValueField( AdsBaseBean bean, Field beanField, EntryAttribute
fieldAttr, boolean mandatory )
+        throws ConfigurationException
     {
         if ( fieldAttr == null )
         {
             return;
         }
-        
+
         Value<?> value = fieldAttr.get();
         String valueStr = value.getString();
         Class<?> type = beanField.getType();
-        
+
         // Process the value accordingly to its type.
         try
         {
@@ -297,11 +301,11 @@ public class ConfigPartitionReader
             }
             else if ( type == int.class )
             {
-                beanField.setInt( bean, Integer.parseInt( valueStr )  );
+                beanField.setInt( bean, Integer.parseInt( valueStr ) );
             }
             else if ( type == long.class )
             {
-                beanField.setLong( bean, Long.parseLong( valueStr )  );
+                beanField.setLong( bean, Long.parseLong( valueStr ) );
             }
             else if ( type == boolean.class )
             {
@@ -316,7 +320,8 @@ public class ConfigPartitionReader
                 }
                 catch ( LdapInvalidDnException lide )
                 {
-                    String message = "The DN '" + valueStr + "' for attribute " + fieldAttr.getId()
+ " is not a valid DN";
+                    String message = "The DN '" + valueStr + "' for attribute " + fieldAttr.getId()
+                        + " is not a valid DN";
                     LOG.error( message );
                     throw new ConfigurationException( message );
                 }
@@ -324,23 +329,24 @@ public class ConfigPartitionReader
         }
         catch ( IllegalArgumentException iae )
         {
-            String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();
;
+            String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();;
             LOG.error( message );
             throw new ConfigurationException( message );
         }
         catch ( IllegalAccessException e )
         {
-            String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();
;
+            String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();;
             LOG.error( message );
             throw new ConfigurationException( message );
         }
     }
-    
-    
+
+
     /**
      * Read the multiple entry value for an AttributeType, and feed the Bean field with this
value
      */
-    private void readMultiValuedField( AdsBaseBean bean, Field beanField, EntryAttribute
fieldAttr, boolean mandatory ) throws ConfigurationException
+    private void readMultiValuedField( AdsBaseBean bean, Field beanField, EntryAttribute
fieldAttr, boolean mandatory )
+        throws ConfigurationException
     {
         if ( fieldAttr == null )
         {
@@ -356,7 +362,7 @@ public class ConfigPartitionReader
         for ( Value<?> value : fieldAttr )
         {
             String valueStr = value.getString();
-            
+
             try
             {
                 if ( type == String.class )
@@ -365,11 +371,11 @@ public class ConfigPartitionReader
                 }
                 else if ( type == int.class )
                 {
-                    beanField.setInt( bean, Integer.parseInt( valueStr )  );
+                    beanField.setInt( bean, Integer.parseInt( valueStr ) );
                 }
                 else if ( type == long.class )
                 {
-                    beanField.setLong( bean, Long.parseLong( valueStr )  );
+                    beanField.setLong( bean, Long.parseLong( valueStr ) );
                 }
                 else if ( type == boolean.class )
                 {
@@ -384,7 +390,8 @@ public class ConfigPartitionReader
                     }
                     catch ( LdapInvalidDnException lide )
                     {
-                        String message = "The DN '" + valueStr + "' for attribute " + fieldAttr.getId()
+ " is not a valid DN";
+                        String message = "The DN '" + valueStr + "' for attribute " + fieldAttr.getId()
+                            + " is not a valid DN";
                         LOG.error( message );
                         throw new ConfigurationException( message );
                     }
@@ -393,52 +400,58 @@ public class ConfigPartitionReader
                 {
                     Type genericFieldType = beanField.getGenericType();
                     Class<?> fieldArgClass = null;
-                        
-                    if ( genericFieldType instanceof ParameterizedType ) 
+
+                    if ( genericFieldType instanceof ParameterizedType )
                     {
-                        ParameterizedType parameterizedType = (ParameterizedType) genericFieldType;
+                        ParameterizedType parameterizedType = ( ParameterizedType ) genericFieldType;
                         Type[] fieldArgTypes = parameterizedType.getActualTypeArguments();
-                        
+
                         for ( Type fieldArgType : fieldArgTypes )
                         {
-                            fieldArgClass = (Class<?>) fieldArgType;
+                            fieldArgClass = ( Class<?> ) fieldArgType;
                         }
                     }
-    
-                    Method method = bean.getClass().getMethod( addMethodName, Array.newInstance(
fieldArgClass, 0 ).getClass() );
-    
-                    method.invoke( bean, new Object[]{ new String[]{valueStr} } );
+
+                    Method method = bean.getClass().getMethod( addMethodName,
+                        Array.newInstance( fieldArgClass, 0 ).getClass() );
+
+                    method.invoke( bean, new Object[]
+                        { new String[]
+                            { valueStr } } );
                 }
                 else if ( type == List.class )
                 {
                     Type genericFieldType = beanField.getGenericType();
                     Class<?> fieldArgClass = null;
-                        
-                    if ( genericFieldType instanceof ParameterizedType ) 
+
+                    if ( genericFieldType instanceof ParameterizedType )
                     {
-                        ParameterizedType parameterizedType = (ParameterizedType) genericFieldType;
+                        ParameterizedType parameterizedType = ( ParameterizedType ) genericFieldType;
                         Type[] fieldArgTypes = parameterizedType.getActualTypeArguments();
-                        
+
                         for ( Type fieldArgType : fieldArgTypes )
                         {
-                            fieldArgClass = (Class<?>) fieldArgType;
+                            fieldArgClass = ( Class<?> ) fieldArgType;
                         }
                     }
-                    
-                    Method method = bean.getClass().getMethod( addMethodName, Array.newInstance(
fieldArgClass, 0 ).getClass() );
-    
-                    method.invoke( bean, new Object[]{ new String[]{valueStr} } );
+
+                    Method method = bean.getClass().getMethod( addMethodName,
+                        Array.newInstance( fieldArgClass, 0 ).getClass() );
+
+                    method.invoke( bean, new Object[]
+                        { new String[]
+                            { valueStr } } );
                 }
             }
             catch ( IllegalArgumentException iae )
             {
-                String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();
;
+                String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();;
                 LOG.error( message );
                 throw new ConfigurationException( message );
             }
             catch ( IllegalAccessException e )
             {
-                String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();
;
+                String message = "Cannot store '" + valueStr + "' into attribute " + fieldAttr.getId();;
                 LOG.error( message );
                 throw new ConfigurationException( message );
             }
@@ -447,7 +460,7 @@ public class ConfigPartitionReader
                 String message = "Cannot access to the class " + bean.getClass().getName();
                 LOG.error( message );
                 throw new ConfigurationException( message );
-            } 
+            }
             catch ( NoSuchMethodException nsme )
             {
                 String message = "Cannot find a method " + addMethodName + " in the class
" + bean.getClass().getName();
@@ -467,46 +480,49 @@ public class ConfigPartitionReader
         }
     }
 
-    
+
     /**
      * Read all the required fields (AttributeTypes) for a given Entry.
      */
-    private void readFields( AdsBaseBean bean, Entry entry, Set<AttributeType> attributeTypes,
boolean mandatory ) throws NoSuchFieldException, IllegalAccessException, Exception
+    private void readFields( AdsBaseBean bean, Entry entry, Set<AttributeType> attributeTypes,
boolean mandatory )
+        throws NoSuchFieldException, IllegalAccessException, Exception
     {
         for ( AttributeType attributeType : attributeTypes )
         {
             String fieldName = attributeType.getName();
             String beanFieldName = fieldName;
-            
+
             // Remove the "ads-" from the beginning of the field name
             if ( fieldName.startsWith( ADS_PREFIX ) )
             {
                 beanFieldName = fieldName.substring( ADS_PREFIX.length() );
             }
-            
+
             // Get the field
             Field beanField = getField( bean.getClass(), beanFieldName, bean.getClass() );
-            
+
             // The field is private, we need to modify it to be able to access it.
             beanField.setAccessible( true );
-            
+
             // Get the entry attribute for this field
             EntryAttribute fieldAttr = entry.get( fieldName );
-            
+
             if ( ( fieldAttr == null ) && ( mandatory ) )
             {
-                String message = "Attribute " + fieldName + " is mandatory and is not present
for the Entry " + entry.getDn();
+                String message = "Attribute " + fieldName + " is mandatory and is not present
for the Entry "
+                    + entry.getDn();
                 LOG.error( message );
                 throw new ConfigurationException( message );
             }
-            
+
             // Get the associated AttributeType
             AttributeType beanAT = schemaManager.getAttributeType( fieldName );
-            
+
             // Check if this AT has the ads-compositeElement as a superior
             AttributeType superior = beanAT.getSuperior();
-            
-            if ( ( superior != null ) && superior.getOid().equals( ConfigSchemaConstants.ADS_COMPOSITE_ELEMENT_AT.getOid()
) )
+
+            if ( ( superior != null )
+                && superior.getOid().equals( ConfigSchemaConstants.ADS_COMPOSITE_ELEMENT_AT.getOid()
) )
             {
                 // This is a composite element, we have to go one level down to read it.
                 // First, check if it's a SingleValued element
@@ -522,25 +538,27 @@ public class ConfigPartitionReader
                         if ( mandatory )
                         {
                             // This is an error !
-                            String message = "The composite " + beanAT.getName() + " is mandatory,
and was not found under the "
+                            String message = "The composite " + beanAT.getName()
+                                + " is mandatory, and was not found under the "
                                 + "configuration entry " + entry.getDn();
                             LOG.error( message );
                             throw new ConfigurationException( message );
                         }
                     }
                     else
-                    { 
+                    {
                         // We must take the first element
                         AdsBaseBean readBean = beans.get( 0 );
-                        
+
                         if ( beans.size() > 1 )
                         {
                             // Not allowed as the AT is singled-valued
-                            String message = "We have more than one entry for " + beanAT.getName()
+ " under " + entry.getDn();
+                            String message = "We have more than one entry for " + beanAT.getName()
+ " under "
+                                + entry.getDn();
                             LOG.error( message );
                             throw new ConfigurationException( message );
                         }
-                        
+
                         beanField.set( bean, readBean );
                     }
                 }
@@ -549,33 +567,34 @@ public class ConfigPartitionReader
                     // No : we have to loop recursively on all the elements which are
                     // under the ou=<element-name> branch
                     DN newBase = entry.getDn().add( "ou=" + beanFieldName );
-                    
+
                     // We have to remove the 's' at the end of the field name
                     String attributeName = fieldName.substring( 0, fieldName.length() - 1
);
-                    
+
                     // Sometime, the plural of a noun takes 'es'
                     if ( !schemaManager.getObjectClassRegistry().contains( attributeName
) )
                     {
                         // Try by removing 'es'
                         attributeName = fieldName.substring( 0, fieldName.length() - 2 );
-                        
+
                         if ( !schemaManager.getObjectClassRegistry().contains( attributeName
) )
                         {
                             String message = "Cannot find the ObjectClass named " + attributeName
+ " in the schema";
-                            LOG.error(  message  );
+                            LOG.error( message );
                             throw new ConfigurationException( message );
                         }
                     }
-                    
+
                     // This is a multi-valued element, it can be a Set or a List
                     Collection<AdsBaseBean> beans = read( newBase, attributeName, SearchScope.ONELEVEL,
mandatory );
-                    
+
                     if ( ( beans == null ) || ( beans.size() == 0 ) )
                     {
                         // If the element is mandatory, this is an error
                         if ( mandatory )
                         {
-                            String message = "The composite " + beanAT.getName() + " is mandatory,
and was not found under the "
+                            String message = "The composite " + beanAT.getName()
+                                + " is mandatory, and was not found under the "
                                 + "configuration entry " + entry.getDn();
                             LOG.error( message );
                             throw new ConfigurationException( message );
@@ -588,7 +607,8 @@ public class ConfigPartitionReader
                     }
                 }
             }
-            else // A standard AttributeType (ie, boolean, long, int or String)
+            else
+            // A standard AttributeType (ie, boolean, long, int or String)
             {
                 // Process the field accordingly to its cardinality
                 if ( beanAT.isSingleValued() )
@@ -602,58 +622,58 @@ public class ConfigPartitionReader
             }
         }
     }
-    
-    
+
+
     /**
      * Get the list of MUST AttributeTypes for an objectClass
      */
     private Set<AttributeType> getAllMusts( ObjectClass objectClass )
     {
         Set<AttributeType> musts = new HashSet<AttributeType>();
-        
+
         // First, gets the direct MUST
         musts.addAll( objectClass.getMustAttributeTypes() );
-        
+
         // then add all the superiors MUST (recursively)
         List<ObjectClass> superiors = objectClass.getSuperiors();
-        
+
         if ( superiors != null )
         {
             for ( ObjectClass superior : superiors )
             {
-                musts.addAll( getAllMusts( superior) );
+                musts.addAll( getAllMusts( superior ) );
             }
         }
-        
+
         return musts;
     }
-    
-    
+
+
     /**
      * Get the list of MAY AttributeTypes for an objectClass
      */
     private Set<AttributeType> getAllMays( ObjectClass objectClass )
     {
         Set<AttributeType> mays = new HashSet<AttributeType>();
-        
+
         // First, gets the direct MAY
         mays.addAll( objectClass.getMayAttributeTypes() );
-        
+
         // then add all the superiors MAY (recursively)
         List<ObjectClass> superiors = objectClass.getSuperiors();
-        
+
         if ( superiors != null )
         {
             for ( ObjectClass superior : superiors )
             {
-                mays.addAll( getAllMays( superior) );
+                mays.addAll( getAllMays( superior ) );
             }
         }
-        
+
         return mays;
     }
-    
-    
+
+
     /**
      * Helper method to print a list of AT's names.
      */
@@ -663,11 +683,11 @@ public class ConfigPartitionReader
         {
             return "";
         }
-        
+
         StringBuilder sb = new StringBuilder();
         boolean isFirst = true;
         sb.append( '{' );
-        
+
         for ( AttributeType attributeType : attributeTypes )
         {
             if ( isFirst )
@@ -678,24 +698,24 @@ public class ConfigPartitionReader
             {
                 sb.append( ", " );
             }
-            
+
             sb.append( attributeType.getName() );
         }
 
         sb.append( '}' );
 
-        
         return sb.toString();
     }
-    
+
 
     /**
      * Read some configuration element from the DIT using its name 
      */
-    private List<AdsBaseBean> read( DN baseDn, String name, SearchScope scope, boolean
mandatory ) throws ConfigurationException
+    private List<AdsBaseBean> read( DN baseDn, String name, SearchScope scope, boolean
mandatory )
+        throws ConfigurationException
     {
         LOG.debug( "Reading from '{}', entry {}", baseDn, name );
-        
+
         // Search for the element starting at some point in the DIT
         // Prepare the search request
         AttributeType adsdAt = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT
);
@@ -703,7 +723,7 @@ public class ConfigPartitionReader
         SearchControls controls = new SearchControls();
         controls.setSearchScope( scope.ordinal() );
         IndexCursor<Long, Entry, Long> cursor = null;
-        
+
         // Create a container for all the read beans
         List<AdsBaseBean> beans = new ArrayList<AdsBaseBean>();
 
@@ -711,14 +731,14 @@ public class ConfigPartitionReader
         {
             // Do the search
             cursor = se.cursor( baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, controls
);
-    
+
             // First, check if we have some entries to process.
             if ( !cursor.next() )
             {
                 if ( mandatory )
                 {
                     cursor.close();
-                    
+
                     // the requested element is mandatory so let's throw an exception
                     String message = "No directoryService instance was configured under the
DN "
                         + configPartition.getSuffix();
@@ -735,30 +755,30 @@ public class ConfigPartitionReader
             do
             {
                 ForwardIndexEntry<Long, Entry, Long> forwardEntry = ( ForwardIndexEntry<Long,
Entry, Long> ) cursor
-                .get();
+                    .get();
 
                 // Now, get the entry
                 Entry entry = configPartition.lookup( forwardEntry.getId() );
                 LOG.debug( "Entry read : {}", entry );
-                
+
                 // Let's instanciate the bean we need. The upper ObjectClass's name
                 // will be used to do that
                 EntryAttribute objectClassAttr = entry.get( SchemaConstants.OBJECT_CLASS_AT
);
-                
+
                 ObjectClass objectClass = findObjectClass( objectClassAttr );
                 AdsBaseBean bean = createBean( objectClass );
-                
+
                 // Now, read the AttributeTypes and store the values into the bean fields
                 // The MAY
                 Set<AttributeType> mays = getAllMays( objectClass );
                 LOG.debug( "Fetching the following MAY attributes : {}", dumpATs( mays )
);
                 readFields( bean, entry, mays, OPTIONNAL );
-                
+
                 // The MUST
                 Set<AttributeType> musts = getAllMusts( objectClass );
                 LOG.debug( "Fetching the following MAY attributes : {}", dumpATs( musts )
);
                 readFields( bean, entry, musts, MANDATORY );
-                
+
                 // Done, we can add the bean into the list
                 beans.add( bean );
             }
@@ -791,12 +811,27 @@ public class ConfigPartitionReader
                 }
             }
         }
-        
+
         return beans;
 
     }
-    
-    
+
+
+    /**
+     * Read the configuration from the DIT, returning a bean containing all of it.
+     * <p>
+     * This method implicitly uses <em>"ou=config"</em> as base DN
+     * 
+     * @return The Config bean, containing the whole configuration
+     * @throws ConfigurationException If we had some issue reading the configuration
+     */
+    public ConfigBean readConfig() throws LdapException
+    {
+        // The starting point is the DirectoryService element
+        return readConfig( new DN( new RDN( SchemaConstants.OU_AT, "config" ) ) );
+    }
+
+
     /**
      * Read the configuration from the DIT, returning a bean containing all of it.
      * 
@@ -809,8 +844,8 @@ public class ConfigPartitionReader
         // The starting point is the DirectoryService element
         return readConfig( new DN( baseDn ), ConfigSchemaConstants.ADS_DIRECTORY_SERVICE_OC.getValue()
);
     }
-    
-    
+
+
     /**
      * Read the configuration from the DIT, returning a bean containing all of it.
      * 
@@ -823,8 +858,8 @@ public class ConfigPartitionReader
         // The starting point is the DirectoryService element
         return readConfig( baseDn, ConfigSchemaConstants.ADS_DIRECTORY_SERVICE_OC.getValue()
);
     }
-    
-    
+
+
     /**
      * Read the configuration from the DIT, returning a bean containing all of it.
      * 
@@ -837,8 +872,8 @@ public class ConfigPartitionReader
     {
         return readConfig( new DN( baseDn ), objectClass );
     }
-    
-    
+
+
     /**
      * Read the configuration from the DIT, returning a bean containing all of it.
      * 
@@ -851,14 +886,14 @@ public class ConfigPartitionReader
     {
         LOG.debug( "Reading configuration for the {} element, from {} ", objectClass, baseDn
);
         ConfigBean configBean = new ConfigBean();
-        
+
         if ( baseDn == null )
         {
             baseDn = configPartition.getSuffix();
         }
-        
+
         List<AdsBaseBean> beans = read( baseDn, objectClass, SearchScope.ONELEVEL,
MANDATORY );
-        
+
         if ( LOG.isDebugEnabled() )
         {
             if ( ( beans == null ) || ( beans.size() == 0 ) )
@@ -870,9 +905,9 @@ public class ConfigPartitionReader
                 LOG.debug( beans.get( 0 ).toString() );
             }
         }
-        
+
         configBean.setDirectoryServiceBeans( beans );
-                
+
         return configBean;
     }
 }



Mime
View raw message