You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by go...@apache.org on 2011/12/26 14:43:45 UTC

svn commit: r1224729 - /directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java

Author: gokturk
Date: Mon Dec 26 13:43:45 2011
New Revision: 1224729

URL: http://svn.apache.org/viewvc?rev=1224729&view=rev
Log:
* Bug Fix on ConfigurationManager,(Check if parent organizational entry is exists for component, if not then create)

Modified:
    directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java

Modified: directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java?rev=1224729&r1=1224728&r2=1224729&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java (original)
+++ directory/apacheds/branches/apacheds-osgi/component-hub/src/main/java/org/apache/directory/server/component/hub/ConfigurationManager.java Mon Dec 26 13:43:45 2011
@@ -46,6 +46,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.entry.StringValue;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.filter.EqualityNode;
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
@@ -106,6 +107,8 @@ public class ConfigurationManager
                 return;
             }
 
+            checkAndCreateComponentParentEntry( component );
+
             List<LdifEntry> componentEntries = generateComponentEntries( component );
 
             for ( LdifEntry le : componentEntries )
@@ -340,4 +343,40 @@ public class ConfigurationManager
 
     }
 
+
+    private void checkAndCreateComponentParentEntry( ADSComponent component )
+    {
+        try
+        {
+            Dn componentBaseDn = new Dn( ADSComponentHelper.getComponentParentRdn( component ) );
+
+            LookupOperationContext loc = new LookupOperationContext( null );
+            loc.setDn( componentBaseDn );
+
+            if ( null != configPartition.lookup( loc ) )
+            {
+                // We have parent entry for component.
+                return;
+            }
+
+            LdifEntry componentParentEntry = new LdifEntry( componentBaseDn,
+                "objectClass:organizationalUnit",
+                "objectClass:top"
+                );
+
+            AddOperationContext aoc = new AddOperationContext( null, componentParentEntry.getEntry() );
+            configPartition.add( aoc );
+        }
+        catch ( LdapInvalidDnException e )
+        {
+            e.printStackTrace();
+            return;
+        }
+        catch ( LdapException e )
+        {
+            LOG.info( "Error while installing base entry for component:" + component );
+            e.printStackTrace();
+            return;
+        }
+    }
 }