directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r503351 - in /directory/apacheds/trunk: constants/src/main/java/org/apache/directory/server/constants/ core/src/main/java/org/apache/directory/server/core/schema/
Date Sun, 04 Feb 2007 03:48:51 GMT
Author: akarasulu
Date: Sat Feb  3 19:48:51 2007
New Revision: 503351

URL: http://svn.apache.org/viewvc?view=rev&rev=503351
Log:
making sure we add the modifiersName and the modifyTimestamp when enabling a schema with the
schema partition dao

Modified:
    directory/apacheds/trunk/constants/src/main/java/org/apache/directory/server/constants/SystemSchemaConstants.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java

Modified: directory/apacheds/trunk/constants/src/main/java/org/apache/directory/server/constants/SystemSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/constants/src/main/java/org/apache/directory/server/constants/SystemSchemaConstants.java?view=diff&rev=503351&r1=503350&r2=503351
==============================================================================
--- directory/apacheds/trunk/constants/src/main/java/org/apache/directory/server/constants/SystemSchemaConstants.java
(original)
+++ directory/apacheds/trunk/constants/src/main/java/org/apache/directory/server/constants/SystemSchemaConstants.java
Sat Feb  3 19:48:51 2007
@@ -34,5 +34,7 @@
     public static final String OBJECT_CLASS_AT = "objectClass";
     public static final String CREATORS_NAME_AT = "creatorsName";
     public static final String CREAT_TIMESTAMP_AT = "createTimestamp";
+    public static final String MODIFY_TIMESTAMP_AT = "modifyTimestamp";
+    public static final String MODIFIERS_NAME_AT = "modifiersName";
     
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?view=diff&rev=503351&r1=503350&r2=503351
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
Sat Feb  3 19:48:51 2007
@@ -259,8 +259,8 @@
      */
     public final void load( Schema schema, Registries targetRegistries, boolean isDepLoad
) throws NamingException
     {
-        // if we're loading a dependency and it has not been enabled on disk
-        // on disk then enable it on disk before we proceed to load it
+        // if we're loading a dependency and it has not been enabled on 
+        // disk then enable it on disk before we proceed to load it
         if ( schema.isDisabled() && isDepLoad )
         {
             dao.enableSchema( schema.getSchemaName() );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?view=diff&rev=503351&r1=503350&r2=503351
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
Sat Feb  3 19:48:51 2007
@@ -38,6 +38,7 @@
 import org.apache.directory.server.constants.SystemSchemaConstants;
 import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.bootstrap.Schema;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.OidRegistry;
@@ -56,6 +57,7 @@
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.syntax.NumericOidSyntaxChecker;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.apache.directory.shared.ldap.util.DateUtils;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,8 +65,19 @@
 
 /**
  * A specialized data access object for managing schema objects in the
- * schema partition.
- *
+ * schema partition.  
+ * 
+ * WARNING:
+ * This dao operates directly on a partition.  Hence no interceptors are available
+ * to perform the various expected services of respective interceptors.  Take care
+ * to normalize all filters and distinguished names.
+ * 
+ * A single write operation exists for enabling schemas needed for operating indices
+ * in partitions and enabling schemas that are dependencies of other schemas that 
+ * are enabled.  In both these limited cases there is no need to worry about issues
+ * with a lack of replication propagation because these same updates will take place
+ * on replicas when the original operation is propagated or when replicas start up.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
@@ -326,13 +339,43 @@
     }
 
 
+    /**
+     * Enables a schema by removing it's m-disabled attribute if present.
+     * 
+     * NOTE:
+     * This is a write operation and great care must be taken to make sure it
+     * is used in a limited capacity.  This method is called in two places 
+     * currently.  
+     * 
+     * (1) Within the initialization sequence to enable schemas required
+     *     for the correct operation of indices in other partitions.
+     * (2) Within the partition schema loader to auto enable schemas that are
+     *     depended on by other schemas which are enabled.
+     * 
+     * In both cases, the modifier is effectively the administrator since the 
+     * server is performing the operation directly or on behalf of a user.  In 
+     * case (1) during intialization there is no other user involved so naturally
+     * the modifier is the administrator.  In case (2) when a user enables a 
+     * schema with a dependency that is not enabled the server enables that 
+     * dependency on behalf of the user.  Again effectively it is the server that
+     * is modifying the schema entry and hence the admin is the modifier.
+     * 
+     * No need to worry about a lack of replication propagation in both cases.  In 
+     * case (1) all replicas will enable these schemas anyway on startup.  In case
+     * (2) the original operation that enabled the schema depending on the on that
+     * enableSchema() is called for itself will be replicated.  Hence the same chain 
+     * reaction will occur in a replica.
+     * 
+     * @param schemaName the name of the schema to enable
+     * @throws NamingException if there is a problem updating the schema entry
+     */
     public void enableSchema( String schemaName ) throws NamingException
     {
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( attrRegistry.getNormalizerMapping() );
         Attributes entry = partition.lookup( dn );
         Attribute disabledAttr = ServerUtils.getAttribute( disabledAttributeType, entry );
-        ModificationItemImpl[] mods = new ModificationItemImpl[1];
+        ModificationItemImpl[] mods = new ModificationItemImpl[3];
         
         if ( disabledAttr == null )
         {
@@ -349,6 +392,10 @@
         
         mods[0] = new ModificationItemImpl( DirContext.REMOVE_ATTRIBUTE, 
             new AttributeImpl( MetaSchemaConstants.M_DISABLED_AT ) );
+        mods[1] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
+            new AttributeImpl( SystemSchemaConstants.MODIFIERS_NAME_AT, PartitionNexus.ADMIN_PRINCIPAL
) );
+        mods[2] = new ModificationItemImpl( DirContext.ADD_ATTRIBUTE,
+            new AttributeImpl( SystemSchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
) );
         
         partition.modify( dn, mods );
     }



Mime
View raw message