directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r504284 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/schema/ schema-registries/src/main/java/org/apache/directory/server/schema/registries/
Date Tue, 06 Feb 2007 20:43:29 GMT
Author: akarasulu
Date: Tue Feb  6 12:43:28 2007
New Revision: 504284

URL: http://svn.apache.org/viewvc?view=rev&rev=504284
Log:
changes ...

 o corrected the DITStructureRule registry so it uses both a composite OID and 
   the rule identifier of a DITStructureRule to look them up
 o fixed the description parsers to correctly handle DITStructureRules
 o fixed the DITStructureRule implementation accordingly 


Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DitStructureRuleImpl.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DITStructureRuleRegistry.java
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultDitStructureRuleRegistry.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java?view=diff&rev=504284&r1=504283&r2=504284
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
Tue Feb  6 12:43:28 2007
@@ -27,7 +27,6 @@
 import javax.naming.directory.Attribute;
 
 import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -68,6 +67,7 @@
 {
     private static final String OTHER_SCHEMA = "other";
     private static final String[] EMPTY = new String[0];
+    private static final Integer[] EMPTY_INT_ARRAY = new Integer[0];
 
     // TODO put these into an interface in the apacheds-constants project 
     private static final String X_SCHEMA = "X-SCHEMA";
@@ -382,19 +382,16 @@
                 throw iave;
             }
             
-            DitStructureRuleImpl dsr = new DitStructureRuleImpl( desc.getNumericOid(), globalRegistries
);
-            dsr.setNameFormOid( desc.getForm() );
-            setSchemaObjectProperties( desc, dsr );
-            
-            // got a problem here
-            // dsr.setSuperClassOids( desc.get )
+            DitStructureRuleImpl dsr = new DitStructureRuleImpl( desc.getNumericOid(), 
+                desc.getRuleId(), globalRegistries );
+            dsr.setSuperClassRuleIds( desc.getSuperRules().toArray( EMPTY_INT_ARRAY ) );
             
+            setSchemaObjectProperties( desc, dsr );
+
             ditStructureRules[ii] = dsr;
         }
         
-        // return ditStructureRules;
-        
-        throw new NotImplementedException( "Don't know how to convert desc to object - object
may be wrong" );
+        return ditStructureRules;
     }
 
     

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DitStructureRuleImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DitStructureRuleImpl.java?view=diff&rev=504284&r1=504283&r2=504284
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DitStructureRuleImpl.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DitStructureRuleImpl.java
Tue Feb  6 12:43:28 2007
@@ -39,18 +39,19 @@
 public class DitStructureRuleImpl extends AbstractSchemaObject implements DITStructureRule,
MutableSchemaObject
 {
     private static final long serialVersionUID = 1L;
-    private final String[] EMPTY_STR_ARRAY = new String[0];
+    private final Integer[] EMPTY_INT_ARRAY = new Integer[0];
     private final DITStructureRule[] EMPTY_DSR_ARRAY = new DITStructureRule[0];
 
     private final Registries registries;
     private String nameFormOid;
-    private String[] superClassOids;
+    private Integer[] superClassRuleIds;
     private DITStructureRule[] superClasses;
     
     
-    public DitStructureRuleImpl( String oid, Registries registries )
+    public DitStructureRuleImpl( String nameFormOid, Integer ruleId, Registries registries
)
     {
-        super( oid );
+        super( nameFormOid + "." + ruleId.toString() );
+        this.nameFormOid = nameFormOid;
         this.registries = registries;
     }
 
@@ -64,42 +65,36 @@
     }
 
     
-    public void setNameFormOid( String nameFormOid )
-    {
-        this.nameFormOid = nameFormOid;
-    }
-    
-
     /* (non-Javadoc)
      * @see org.apache.directory.shared.ldap.schema.DITStructureRule#getSuperClasses()
      */
     public DITStructureRule[] getSuperClasses() throws NamingException
     {
-        if ( this.superClassOids == null )
+        if ( this.superClassRuleIds == null )
         {
             return EMPTY_DSR_ARRAY;
         }
         
-        for ( int ii = 0; ii < superClassOids.length; ii++ )
+        for ( int ii = 0; ii < superClassRuleIds.length; ii++ )
         {
-            superClasses[ii] = registries.getDitStructureRuleRegistry().lookup( superClassOids[ii]
);
+            superClasses[ii] = registries.getDitStructureRuleRegistry().lookup( superClassRuleIds[ii]
);
         }
         
         return superClasses;
     }
     
     
-    public void setSuperClassOids( String[] superClassOids )
+    public void setSuperClassRuleIds( Integer[] superClassRuleIds )
     {
-        if ( superClassOids == null )
+        if ( superClassRuleIds == null )
         {
-            this.superClassOids = EMPTY_STR_ARRAY;
+            this.superClassRuleIds = EMPTY_INT_ARRAY;
             this.superClasses = EMPTY_DSR_ARRAY;
         }
         else
         {
-            this.superClassOids = superClassOids;
-            this.superClasses = new DITStructureRule[superClassOids.length];
+            this.superClassRuleIds = superClassRuleIds;
+            this.superClasses = new DITStructureRule[superClassRuleIds.length];
         }
     }
     
@@ -125,5 +120,11 @@
     public void setDescription( String description )
     {
         super.setDescription( description );
+    }
+
+
+    public Integer getRuleId()
+    {
+        return null;
     }
 }

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DITStructureRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DITStructureRuleRegistry.java?view=diff&rev=504284&r1=504283&r2=504284
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DITStructureRuleRegistry.java
(original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DITStructureRuleRegistry.java
Tue Feb  6 12:43:28 2007
@@ -46,10 +46,13 @@
 
 
     /**
-     * Looks up an dITStructureRule by its unique Object IDentifier or by its
-     * name.
+     * Looks up an dITStructureRule using a composite key composed of the
+     * nameForm object identifier with a DOT and the rule id of the 
+     * DITStructureRule appended to it.  If the name form object identifier
+     * is 1.2.3.4 and the rule identifier is 5 then the OID used for the 
+     * lookup is 1.2.3.4.5.
      * 
-     * @param id the object identifier, or the name
+     * @param id the nameForm object identifier with rule identifier appended
      * @return the DITStructureRule instance for the id
      * @throws NamingException if the DITStructureRule does not exist
      */
@@ -57,13 +60,54 @@
 
 
     /**
-     * Checks to see if an dITStructureRule exists.
+     * Looks up an dITStructureRule by its unique Object IDentifier or by its
+     * name.
+     * 
+     * @param ruleId the rule identifier for the DITStructureRule
+     * @return the DITStructureRule instance for rule identifier
+     * @throws NamingException if the DITStructureRule does not exist
+     */
+    DITStructureRule lookup( Integer ruleId ) throws NamingException;
+
+
+    /**
+     * Checks to see if an dITStructureRule exists using the object identifier
+     * of the nameForm appended with the rule identifier of the DITStructureRule.
      * 
-     * @param id the object identifier, or the name
+     * @param id the object identifier of the nameForm with the rule Id appended
      * @return true if an dITStructureRule definition exists for the id, false
      * otherwise
      */
     boolean hasDITStructureRule( String id );
+
+
+    /**
+     * Checks to see if an dITStructureRule exists using the rule identifier.
+     * 
+     * @param ruleId the rule identifier for the DITStructureRule.
+     * @return true if an dITStructureRule definition exists for the id, false
+     * otherwise
+     */
+    boolean hasDITStructureRule( Integer ruleId );
+
+    
+    /**
+     * Unregisters a DITStructureRule using it's rule identifier. 
+     * 
+     * @param ruleId the rule identifier for the DITStructureRule to unregister
+     * @throws NamingException if no such DITStructureRule exists
+     */
+    void unregister( Integer ruleId ) throws NamingException;
+    
+    
+    /**
+     * Gets the schema name for a DITStructureRule using the rule identifier. 
+     * 
+     * @param ruleId the rule identifier for the DITStructureRule
+     * @return the schema name for the DITStructureRule
+     * @throws NamingException if no such rule could be found
+     */
+    String getSchemaName( Integer ruleId ) throws NamingException;
 
 
     /**

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultDitStructureRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultDitStructureRuleRegistry.java?view=diff&rev=504284&r1=504283&r2=504284
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultDitStructureRuleRegistry.java
(original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultDitStructureRuleRegistry.java
Tue Feb  6 12:43:28 2007
@@ -26,6 +26,8 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.exception.LdapNamingException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.DITStructureRule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,6 +45,8 @@
     private final static Logger log = LoggerFactory.getLogger( DefaultDitStructureRuleRegistry.class
);
     /** maps an OID to an DITStructureRule */
     private final Map<String,DITStructureRule> byOid;
+    /** maps an OID to an DITStructureRule */
+    private final Map<Integer,DITStructureRule> byRuleId;
     /** the registry used to resolve names to OIDs */
     private final OidRegistry oidRegistry;
 
@@ -57,6 +61,7 @@
      */
     public DefaultDitStructureRuleRegistry(OidRegistry oidRegistry)
     {
+        this.byRuleId = new HashMap<Integer,DITStructureRule>();
         this.byOid = new HashMap<String,DITStructureRule>();
         this.oidRegistry = oidRegistry;
     }
@@ -77,6 +82,7 @@
 
         oidRegistry.register( dITStructureRule.getName(), dITStructureRule.getOid() );
         byOid.put( dITStructureRule.getOid(), dITStructureRule );
+        byRuleId.put( dITStructureRule.getRuleId(), dITStructureRule );
         if ( log.isDebugEnabled() )
         {
             log.debug( "registered dITStructureRule: " + dITStructureRule );
@@ -134,10 +140,41 @@
     }
 
 
+    public String getSchemaName( Integer ruleId ) throws NamingException
+    {
+        DITStructureRule dsr = byRuleId.get( ruleId );
+        if ( dsr != null )
+        {
+            return dsr.getSchema();
+        }
+
+        throw new NamingException( "A DitStructureRule with ruleId " + ruleId 
+            + " not found in the DITStructureRule map!" );
+    }
+
+
     public Iterator<DITStructureRule> iterator()
     {
         return byOid.values().iterator();
     }
+
+    
+    public void unregister( Integer ruleId ) throws NamingException
+    {
+        DITStructureRule dsr = byRuleId.remove( ruleId );
+        
+        if ( dsr == null )
+        {
+            if ( dsr == null )
+            {
+                throw new LdapNamingException(
+                    "No such DITStructureRule for rule identifier: " + ruleId,
+                    ResultCodeEnum.OTHER );
+            }
+        }
+        
+        byOid.remove( dsr.getOid() );
+    }
     
     
     public void unregister( String numericOid ) throws NamingException
@@ -147,6 +184,36 @@
             throw new NamingException( "Looks like the arg is not a numeric OID" );
         }
 
-        byOid.remove( numericOid );
+        DITStructureRule dsr = byOid.remove( numericOid );
+        byRuleId.remove( dsr.getRuleId() );
+    }
+
+
+    public boolean hasDITStructureRule( Integer ruleId )
+    {
+        DITStructureRule dsr = byRuleId.get( ruleId );
+        if ( dsr == null )
+        {
+            return false;
+        }
+        else
+        {
+            return true;
+        }
+    }
+
+
+    public DITStructureRule lookup( Integer ruleId ) throws NamingException
+    {
+        DITStructureRule dsr = byRuleId.get( ruleId );
+        
+        if ( dsr == null )
+        {
+            throw new LdapNamingException(
+                "No such DITStructureRule for rule identifier: " + ruleId,
+                ResultCodeEnum.OTHER );
+        }
+
+        return dsr;
     }
 }



Mime
View raw message