directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r679249 - /directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java
Date Thu, 24 Jul 2008 00:47:40 GMT
Author: akarasulu
Date: Wed Jul 23 17:47:39 2008
New Revision: 679249

URL: http://svn.apache.org/viewvc?rev=679249&view=rev
Log:
fixing bugs with preferences due to switch to absolute names rather than relative names using
JNDI

Modified:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java?rev=679249&r1=679248&r2=679249&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/prefs/ServerSystemPreferences.java
Wed Jul 23 17:47:39 2008
@@ -37,6 +37,7 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.PreferencesDictionary;
 
+import javax.naming.InvalidNameException;
 import javax.naming.NamingException;
 
 import java.util.ArrayList;
@@ -81,7 +82,16 @@
     {
         super( null, "" );
         super.newNode = false;
-        dn = new LdapDN();
+        
+        try
+        {
+            dn = new LdapDN( "prefNodeName=sysPrefRoot,ou=system" );
+        }
+        catch ( InvalidNameException e )
+        {
+            // never happens
+        }
+        
         this.directoryService = directoryService;
     }
 
@@ -101,29 +111,29 @@
     {
         super( parent, name );
 
+        this.directoryService = parent.directoryService;
+        LdapDN parentDn = ( ( ServerSystemPreferences ) parent() ).dn;
         try
         {
-            dn = new LdapDN( "prefNodeName=" + name );
-            super.newNode = false;
-            this.directoryService = parent.directoryService;
+            dn = new LdapDN( "prefNodeName=" + name + "," + parentDn.getUpName() );
             dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping()
);
-        }
-        catch ( NamingException e )
-        {
-            super.newNode = true;
-        }
-
-        if ( super.newNode )
-        {
-            try
-            {
-                setUpNode( name );
-            }
-            catch ( Exception e )
+            
+            if ( ! directoryService.getAdminSession().exists( dn ) )
             {
-                throw new ServerSystemPreferenceException( "Failed to set up node.", e );
+                ServerEntry entry = directoryService.newEntry( dn );
+                entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, 
+                    ApacheSchemaConstants.PREF_NODE_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC
);
+                entry.add( "prefNodeName", name );
+    
+                directoryService.getAdminSession().add( entry );
+                
+                super.newNode = false;
             }
         }
+        catch ( Exception e )
+        {
+            throw new ServerSystemPreferenceException( "Failed to set up node.", e );
+        }
     }
 
 
@@ -142,28 +152,6 @@
     }
 
 
-    /**
-     * Sets up a new ServerPreferences node by injecting the required information
-     * such as the node name attribute and the objectClass attribute.
-     *
-     * @param name the name of the new ServerPreferences node
-     * @throws NamingException if we fail to created the new node
-     */
-    private void setUpNode( String name ) throws Exception
-    {
-        LdapDN parent = ( ( ServerSystemPreferences ) parent() ).dn;
-        LdapDN child = new LdapDN( parent.getNormName() + ",prefNodeName=" + name );
-        child.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping()
);
-        ServerEntry entry = directoryService.newEntry( child );
-        entry.add( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, 
-            ApacheSchemaConstants.PREF_NODE_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
-        entry.add( "prefNodeName", name );
-
-        directoryService.getAdminSession().add( entry );
-        super.newNode = false;
-    }
-
-
     // ------------------------------------------------------------------------
     // Protected SPI Methods
     // ------------------------------------------------------------------------
@@ -262,8 +250,7 @@
                 ServerAttribute sa = ( ServerAttribute ) attr;
                 String oid = sa.getAttributeType().getOid();
                 
-                if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) || 
-                     oid.equals( ApacheSchemaConstants.PREF_NODE_NAME_AT_OID ) )
+                if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
                 {
                     continue;
                 }
@@ -321,7 +308,7 @@
     {
         try
         {
-            EntryAttribute attr = null;
+            EntryAttribute attr = directoryService.getAdminSession().lookup( dn ).get( key
);
             
             if ( keyToChange.containsKey( key ) )
             {
@@ -344,7 +331,7 @@
             }
             else
             {
-                return attr.getUpId();
+                return attr.getString();
             }
         }
         catch ( Exception e )



Mime
View raw message