directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r807786 [1/2] - in /directory/shared/branches/shared-schema/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/schema/ main/java/org/apache/directory/shared/ldap/schema/parsers/ main/java/org/apache/directory/shared/ldap/schem...
Date Tue, 25 Aug 2009 20:00:34 GMT
Author: elecharny
Date: Tue Aug 25 20:00:33 2009
New Revision: 807786

URL: http://svn.apache.org/viewvc?rev=807786&view=rev
Log:
o Added the AttributeType class
o Fixed the parser tests for this class
o Many other fixes and improvements in other classes

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/AttributeTypeDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
    directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/syntax/parser/AttributeTypeDescriptionSchemaParserTest.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/antlr/schema.g Tue Aug 25 20:00:33
2009
@@ -35,7 +35,7 @@
 import org.apache.directory.shared.ldap.schema.NameForm;
 import org.apache.directory.shared.ldap.schema.parsers.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.parsers.ParserMonitor;
-import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.schema.syntaxChecker.OpenLdapObjectIdentifierMacro;
@@ -246,7 +246,7 @@
 
 openLdapSchema returns [List<Object> list = new ArrayList<Object>()]
     {
-        AttributeTypeDescription atd = null;
+        AttributeType attributeType = null;
         ObjectClassDescription ocd = null;
         OpenLdapObjectIdentifierMacro oloid = null;
     }
@@ -254,7 +254,7 @@
     (
         oloid = openLdapObjectIdentifier { list.add( oloid ); }
         |
-        atd = openLdapAttributeType { list.add( atd ); }
+        attributeType = openLdapAttributeType { list.add( attributeType ); }
         |
         ocd = openLdapObjectClass { list.add( ocd ); }
     )*
@@ -289,14 +289,14 @@
     ;
     
     
-openLdapAttributeType returns [AttributeTypeDescription atd]
+openLdapAttributeType returns [AttributeType attributeType]
     {
         matchedProduction( "openLdapAttributeType()" );
     }
     :
     (
         ATTRIBUTETYPE
-        ( atd=attributeTypeDescription )
+        ( attributeType=attributeTypeDescription )
     )
     ;
 
@@ -390,54 +390,54 @@
      * xstring = "X" HYPHEN 1*( ALPHA / HYPHEN / USCORE ) 
      * </pre>
     */
-attributeTypeDescription returns [AttributeTypeDescription atd = new AttributeTypeDescription()]
+attributeTypeDescription returns [AttributeType attributeType]
     {
         matchedProduction( "attributeTypeDescription()" );
         ElementTracker et = new ElementTracker();
     }
     :
-    ( oid:STARTNUMERICOID { atd.setNumericOid(numericoid(oid.getText())); } )
+    ( oid:STARTNUMERICOID { attributeType = new AttributeType(numericoid(oid.getText()));
} )
     (
-        ( name:NAME { et.track("NAME", name); atd.setNames(qdescrs(name.getText())); } )
+        ( name:NAME { et.track("NAME", name); attributeType.setNames(qdescrs(name.getText()));
} )
         |
-        ( desc:DESC { et.track("DESC", desc); atd.setDescription(qdstring(desc.getText()));
} )
+        ( desc:DESC { et.track("DESC", desc); attributeType.setDescription(qdstring(desc.getText()));
} )
         |
-        ( obsolete:OBSOLETE { et.track("OBSOLETE", obsolete); atd.setObsolete( true ); }
)
+        ( obsolete:OBSOLETE { et.track("OBSOLETE", obsolete); attributeType.setObsolete(
true ); } )
         |
-        ( sup:SUP { et.track("SUP", sup); atd.setSuperType(oid(sup.getText())); } )
+        ( sup:SUP { et.track("SUP", sup); attributeType.setSuperiorOid(oid(sup.getText()));
} )
         |
-        ( equality:EQUALITY { et.track("EQUALITY", equality); atd.setEqualityMatchingRule(oid(equality.getText()));
} )
+        ( equality:EQUALITY { et.track("EQUALITY", equality); attributeType.setEqualityOid(oid(equality.getText()));
} )
         |
-        ( ordering:ORDERING { et.track("ORDERING", ordering); atd.setOrderingMatchingRule(oid(ordering.getText()));
} )
+        ( ordering:ORDERING { et.track("ORDERING", ordering); attributeType.setOrderingOid(oid(ordering.getText()));
} )
         |
-        ( substr:SUBSTR { et.track("SUBSTR", substr); atd.setSubstringsMatchingRule(oid(substr.getText()));
} )
+        ( substr:SUBSTR { et.track("SUBSTR", substr); attributeType.setSubstrOid(oid(substr.getText()));
} )
         |
         ( syntax:SYNTAX { 
            et.track("SYNTAX", syntax); 
             NoidLen noidlen = noidlen(syntax.getText());
-            atd.setSyntax(noidlen.noid); 
-            atd.setSyntaxLength(noidlen.len);
+            attributeType.setSyntaxOid(noidlen.noid); 
+            attributeType.setLength(noidlen.len);
           } )
         |
-        ( singleValue:SINGLE_VALUE { et.track("SINGLE_VALUE", singleValue); atd.setSingleValued(
true ); } )
+        ( singleValue:SINGLE_VALUE { et.track("SINGLE_VALUE", singleValue); attributeType.setSingleValue(
true ); } )
         |
-        ( collective:COLLECTIVE { et.track("COLLECTIVE", collective); atd.setCollective(
true ); } )
+        ( collective:COLLECTIVE { et.track("COLLECTIVE", collective); attributeType.setCollective(
true ); } )
         |
-        ( noUserModification:NO_USER_MODIFICATION { et.track("NO_USER_MODIFICATION", noUserModification);
atd.setUserModifiable( false ); } )
+        ( noUserModification:NO_USER_MODIFICATION { et.track("NO_USER_MODIFICATION", noUserModification);
attributeType.setCanUserModify( false ); } )
         |
-        ( usage1:USAGE (WHSP)* USER_APPLICATIONS { et.track("USAGE", usage1); atd.setUsage(
UsageEnum.USER_APPLICATIONS ); }
+        ( usage1:USAGE (WHSP)* USER_APPLICATIONS { et.track("USAGE", usage1); attributeType.setUsage(
UsageEnum.USER_APPLICATIONS ); }
           |
-          usage2:USAGE DIRECTORY_OPERATION { et.track("USAGE", usage2); atd.setUsage( UsageEnum.DIRECTORY_OPERATION
); }
+          usage2:USAGE DIRECTORY_OPERATION { et.track("USAGE", usage2); attributeType.setUsage(
UsageEnum.DIRECTORY_OPERATION ); }
           |
-          usage3:USAGE DISTRIBUTED_OPERATION { et.track("USAGE", usage3); atd.setUsage( UsageEnum.DISTRIBUTED_OPERATION
); } 
+          usage3:USAGE DISTRIBUTED_OPERATION { et.track("USAGE", usage3); attributeType.setUsage(
UsageEnum.DISTRIBUTED_OPERATION ); } 
           |
-          usage4:USAGE DSA_OPERATION { et.track("USAGE", usage4); atd.setUsage( UsageEnum.DSA_OPERATION
); } 
+          usage4:USAGE DSA_OPERATION { et.track("USAGE", usage4); attributeType.setUsage(
UsageEnum.DSA_OPERATION ); } 
         )
         |
         ( extension:EXTENSION { 
             Extension ex = extension(extension.getText());
             et.track(ex.key, extension); 
-            atd.addExtension(ex.key, ex.values); 
+            attributeType.addExtension(ex.key, ex.values); 
          } )
     )*    
     RPAR
@@ -451,13 +451,13 @@
             }
         
             // COLLECTIVE requires USAGE userApplications
-            if ( atd.isCollective() && ( atd.getUsage() != UsageEnum.USER_APPLICATIONS
) )
+            if ( attributeType.isCollective() && ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS
) )
             {
                 throw new SemanticException( "COLLECTIVE requires USAGE userApplications",
null, 0, 0 );
             }
         
             // NO-USER-MODIFICATION requires an operational USAGE.
-            if ( !atd.isUserModifiable() && ( atd.getUsage() == UsageEnum.USER_APPLICATIONS
) )
+            if ( !attributeType.isCanUserModify() && ( attributeType.getUsage() ==
UsageEnum.USER_APPLICATIONS ) )
             {
                 throw new SemanticException( "NO-USER-MODIFICATION requires an operational
USAGE", null, 0, 0 );
             }
@@ -577,7 +577,7 @@
         |
         ( obsolete:OBSOLETE { et.track("OBSOLETE", obsolete); matchingRuleUse.setObsolete(
true ); } )
         |
-        ( applies:APPLIES { et.track("APPLIES", applies); matchingRuleUse.setApplicableAttributes(oids(applies.getText()));
} )
+        ( applies:APPLIES { et.track("APPLIES", applies); matchingRuleUse.setApplicableAttributeOids(oids(applies.getText()));
} )
         |
         ( extension:EXTENSION { 
             Extension ex = extension(extension.getText());
@@ -733,7 +733,7 @@
         |
         ( obsolete:OBSOLETE { et.track("OBSOLETE", obsolete); nameForm.setObsolete( true
); } )
         |
-        ( oc:OC { et.track("OC", oc); nameForm.setStructuralObjectClass(oid(oc.getText()));
} )
+        ( oc:OC { et.track("OC", oc); nameForm.setStructuralObjectClassOid(oid(oc.getText()));
} )
         |
         ( must:MUST { et.track("MUST", must); nameForm.setMustAttributeTypeOids(oids(must.getText()));
} )
         |

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
Tue Aug 25 20:00:33 2009
@@ -182,7 +182,7 @@
     private UsageEnum usage = UsageEnum.USER_APPLICATIONS;
 
     /** the length of this attribute in bytes */
-    private int length = -1;
+    private int length = 0;
     
     /**
      * Creates a AttributeType object using a unique OID.
@@ -383,13 +383,28 @@
      *
      * @param superiorOid The superior AttributeType OID of this AttributeType
      */
-    public void setSuperiorOid( String superiorOid ) throws NamingException
+    public void setSuperiorOid( String superiorOid )
     {
         if ( !isReadOnly )
         {
             this.supOid = superiorOid;
         }
     }
+    
+
+    /**
+     * Sets the superior for this AttributeType
+     *
+     * @param superior The superior for this AttributeType
+     */
+    public void setSuperior( AttributeType superior )
+    {
+        if ( !isReadOnly )
+        {
+            this.sup = superior;
+            this.supOid = superior.getOid();
+        }
+    }
 
 
     /**
@@ -418,15 +433,29 @@
      * Sets the Syntax OID for this AttributeType
      *
      * @param superiorOid The syntax OID for this AttributeType
-     * @throws NamingException if there is a failure to resolve the matchingRule
      */
-    public void setSyntaxOid( String syntaxOid ) throws NamingException
+    public void setSyntaxOid( String syntaxOid )
     {
         if ( !isReadOnly )
         {
             this.syntaxOid = syntaxOid;
         }
     }
+    
+
+    /**
+     * Sets the Syntax for this AttributeType
+     *
+     * @param syntax The Syntax for this AttributeType
+     */
+    public void setSyntax( LdapSyntax syntax )
+    {
+        if ( !isReadOnly )
+        {
+            this.syntax = syntax;
+            this.syntaxOid = syntax.getOid();
+        }
+    }
 
     
     /**
@@ -455,9 +484,8 @@
      * Sets the Equality OID for this AttributeType
      *
      * @param equalityOid The Equality OID for this AttributeType
-     * @throws NamingException if there is a failure to resolve the matchingRule
      */
-    public void setEqualityOid( String equalityOid ) throws NamingException
+    public void setEqualityOid( String equalityOid )
     {
         if ( !isReadOnly )
         {
@@ -467,6 +495,21 @@
     
 
     /**
+     * Sets the Equality MR for this AttributeType
+     *
+     * @param equality The Equality MR for this AttributeType
+     */
+    public void setEquality( MatchingRule equality )
+    {
+        if ( !isReadOnly )
+        {
+            this.equality = equality;
+            this.equalityOid = equality.getOid();
+        }
+    }
+    
+
+    /**
      * Gets the MatchingRule for this AttributeType used for Ordering matching.
      * 
      * @return the Ordering matching rule
@@ -492,15 +535,29 @@
      * Sets the Ordering OID for this AttributeType
      *
      * @param orderingOid The Ordering OID for this AttributeType
-     * @throws NamingException if there is a failure to resolve the matchingRule
      */
-    public void setOrderingOid( String orderingOid ) throws NamingException
+    public void setOrderingOid( String orderingOid )
     {
         if ( !isReadOnly )
         {
             this.orderingOid = orderingOid;
         }
     }
+    
+
+    /**
+     * Sets the Ordering MR for this AttributeType
+     *
+     * @param ordering The Ordering MR for this AttributeType
+     */
+    public void setOrdering( MatchingRule ordering )
+    {
+        if ( !isReadOnly )
+        {
+            this.ordering = ordering;
+            this.orderingOid = ordering.getOid();
+        }
+    }
 
     
     /**
@@ -529,15 +586,29 @@
      * Sets the Substr OID for this AttributeType
      *
      * @param substrOid The Substr OID for this AttributeType
-     * @throws NamingException if there is a failure to resolve the matchingRule
      */
-    public void setSubstrOid( String substrOid ) throws NamingException
+    public void setSubstrOid( String substrOid )
     {
         if ( !isReadOnly )
         {
             this.substrOid = substrOid;
         }
     }
+    
+
+    /**
+     * Sets the Substr MR for this AttributeType
+     *
+     * @param substr The Substr MR for this AttributeType
+     */
+    public void setSubstr( MatchingRule substr )
+    {
+        if ( !isReadOnly )
+        {
+            this.substr = substr;
+            this.substrOid = substr.getOid();
+        }
+    }
 
 
     /**
@@ -545,10 +616,9 @@
      * attributeType.
      *
      * @param descendant the perspective descendant to check
-     * @return true if the descendant is truely a derived from this AttributeType
-     * @throws NamingException if there are problems resolving superior types
+     * @return true if the descendant is truly a derived from this AttributeType
      */
-    public boolean isAncestorOf( AttributeType descendant ) throws NamingException
+    public boolean isAncestorOf( AttributeType descendant )
     {
         if ( ( descendant == null ) || this.equals( descendant ) )
         {
@@ -564,10 +634,9 @@
      * attributeType.
      *
      * @param ancestor the perspective ancestor to check
-     * @return true if this AttributeType truely descends from the ancestor
-     * @throws NamingException if there are problems resolving superior types
+     * @return true if this AttributeType truly descends from the ancestor
      */
-    public boolean isDescendantOf( AttributeType ancestor ) throws NamingException
+    public boolean isDescendantOf( AttributeType ancestor )
     {
         if ( ( ancestor == null ) || equals( ancestor ) )
         {
@@ -588,9 +657,8 @@
      * @param descendant the possible descendant of the ancestor
      * @return true if the ancestor equals the descendant or if the descendant is really
      * a subtype of the ancestor. otherwise false
-     * @throws NamingException if there are issues with superior attribute resolution
      */
-    private boolean isAncestorOrEqual( AttributeType ancestor, AttributeType descendant )
throws NamingException
+    private boolean isAncestorOrEqual( AttributeType ancestor, AttributeType descendant )
     {
         if ( ( ancestor == null ) || ( descendant == null ) )
         {

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
Tue Aug 25 20:00:33 2009
@@ -169,6 +169,38 @@
         return auxObjectClassOids;
     }
 
+    
+    /**
+     * Add an Auxiliary ObjectClass Oid
+     *
+     * @param oid The ObjectClass oid
+     */
+    public void addAuxObjectClassOidOids( String oid )
+    {
+        if ( !isReadOnly )
+        {
+            auxObjectClassOids.add( oid );
+        }
+    }
+
+
+    /**
+     * Add an Auxiliary ObjectClass
+     *
+     * @param oid The ObjectClass
+     */
+    public void addAuxObjectClasses( ObjectClass objectClass )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! auxObjectClassOids.contains( objectClass.getOid() ) )
+            {
+                auxObjectClasses.add( objectClass );
+                auxObjectClassOids.add( objectClass.getOid() );
+            }
+        }
+    }
+    
 
     /**
      * @param auxObjectClassOids the auxObjectClassOids to set
@@ -183,6 +215,26 @@
 
 
     /**
+     * @param auxObjectClasses the auxObjectClasses to set
+     */
+    public void setAuxObjectClasses( List<ObjectClass> auxObjectClasses )
+    {
+        if ( !isReadOnly )
+        {
+            this.auxObjectClasses = auxObjectClasses;
+            
+            // update the OIDS now
+            auxObjectClassOids.clear();
+            
+            for ( ObjectClass oc : auxObjectClasses )
+            {
+                auxObjectClassOids.add( oc.getOid() );
+            }
+        }
+    }
+    
+    
+    /**
      * @return the auxObjectClasses
      */
     public List<ObjectClass> getAuxObjectClasses()
@@ -201,6 +253,38 @@
 
 
     /**
+     * Add an allowed AttributeType
+     *
+     * @param oid The attributeType oid
+     */
+    public void addMayAttributeTypeOids( String oid )
+    {
+        if ( !isReadOnly )
+        {
+            mayAttributeTypeOids.add( oid );
+        }
+    }
+
+
+    /**
+     * Add an allowed AttributeType
+     *
+     * @param attributeType The attributeType
+     */
+    public void addMayAttributeTypes( AttributeType attributeType )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! mayAttributeTypeOids.contains( attributeType.getOid() ) )
+            {
+                mayAttributeTypes.add( attributeType );
+                mayAttributeTypeOids.add( attributeType.getOid() );
+            }
+        }
+    }
+
+    
+    /**
      * @param mayAttributeTypeOids the mayAttributeTypeOids to set
      */
     public void setMayAttributeTypeOids( List<String> mayAttributeTypeOids )
@@ -210,6 +294,28 @@
             this.mayAttributeTypeOids = mayAttributeTypeOids;
         }
     }
+    
+    
+    /**
+     * Sets the list of allowed AttributeTypes
+     *
+     * @param mayAttributeTypes the list of allowed AttributeTypes
+     */
+    public void setMayAttributeTypes( List<AttributeType> mayAttributeTypes )
+    {
+        if ( !isReadOnly )
+        {
+            this.mayAttributeTypes = mayAttributeTypes;
+            
+            // update the OIDS now
+            mayAttributeTypeOids.clear();
+            
+            for ( AttributeType may : mayAttributeTypes )
+            {
+                mayAttributeTypeOids.add( may.getOid() );
+            }
+        }
+    }
 
 
     /**
@@ -229,6 +335,38 @@
         return mustAttributeTypeOids;
     }
 
+    
+    /**
+     * Add a required AttributeType OID
+     *
+     * @param oid The attributeType OID
+     */
+    public void addMustAttributeTypeOids( String oid )
+    {
+        if ( !isReadOnly )
+        {
+            mustAttributeTypeOids.add( oid );
+        }
+    }
+
+
+    /**
+     * Add a required AttributeType
+     *
+     * @param attributeType The attributeType
+     */
+    public void addMustAttributeTypes( AttributeType attributeType )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! mustAttributeTypeOids.contains( attributeType.getOid() ) )
+            {
+                mustAttributeTypes.add( attributeType );
+                mustAttributeTypeOids.add( attributeType.getOid() );
+            }
+        }
+    }
+
 
     /**
      * @param mustAttributeTypeOids the mustAttributeTypeOids to set
@@ -241,6 +379,28 @@
         }
     }
 
+    
+    /**
+     * Sets the list of required AttributeTypes
+     *
+     * @param mayAttributeTypes the list of required AttributeTypes
+     */
+    public void setMustAttributeTypes( List<AttributeType> mustAttributeTypes )
+    {
+        if ( !isReadOnly )
+        {
+            this.mustAttributeTypes = mustAttributeTypes;
+            
+            // update the OIDS now
+            mustAttributeTypeOids.clear();
+            
+            for ( AttributeType may : mustAttributeTypes )
+            {
+                mustAttributeTypeOids.add( may.getOid() );
+            }
+        }
+    }
+
 
     /**
      * @return the mustAttributeTypes
@@ -261,6 +421,38 @@
 
 
     /**
+     * Add a precluded AttributeType
+     *
+     * @param oid The attributeType oid
+     */
+    public void addNotAttributeTypeOids( String oid )
+    {
+        if ( !isReadOnly )
+        {
+            notAttributeTypeOids.add( oid );
+        }
+    }
+
+
+    /**
+     * Add a precluded AttributeType
+     *
+     * @param attributeType The attributeType
+     */
+    public void addNotAttributeTypes( AttributeType attributeType )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! notAttributeTypeOids.contains( attributeType.getOid() ) )
+            {
+                notAttributeTypes.add( attributeType );
+                notAttributeTypeOids.add( attributeType.getOid() );
+            }
+        }
+    }
+
+
+    /**
      * @param notAttributeTypeOids the notAttributeTypeOids to set
      */
     public void setNotAttributeTypeOids( List<String> notAttributeTypeOids )
@@ -271,6 +463,28 @@
         }
     }
 
+    
+    /**
+     * Sets the list of precluded AttributeTypes
+     *
+     * @param mayAttributeTypes the list of precluded AttributeTypes
+     */
+    public void setNotAttributeTypes( List<AttributeType> notAttributeTypes )
+    {
+        if ( !isReadOnly )
+        {
+            this.notAttributeTypes = notAttributeTypes;
+            
+            // update the OIDS now
+            notAttributeTypeOids.clear();
+            
+            for ( AttributeType not : notAttributeTypes )
+            {
+                notAttributeTypeOids.add( not.getOid() );
+            }
+        }
+    }
+
 
     /**
      * @return the notAttributeTypes

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
Tue Aug 25 20:00:33 2009
@@ -164,6 +164,22 @@
         }
     }
 
+    
+    /**
+     * Sets the Syntax
+     *
+     * @param oid The Syntax
+     */
+    public void setSyntax( LdapSyntax ldapSyntax )
+    {
+        if ( !isReadOnly )
+        {
+            this.ldapSyntax = ldapSyntax;
+            this.ldapSyntaxOid = ldapSyntax.getOid();
+        }
+    }
+
+
     /**
      * Gets the LdapComparator enabling the use of this MatchingRule for ORDERING
      * and sorted indexing.
@@ -178,6 +194,20 @@
 
 
     /**
+     * Sets the LdapComparator
+     *
+     * @param oid The LdapComparator
+     */
+    public void setLdapComparator( LdapComparator<? super Object> ldapComparator )
+    {
+        if ( !isReadOnly )
+        {
+            this.ldapComparator = ldapComparator;
+        }
+    }
+
+
+    /**
      * Gets the Normalizer enabling the use of this MatchingRule for EQUALITY
      * matching and indexing.
      * 
@@ -188,4 +218,20 @@
     {
         return normalizer;
     }
+
+
+    /**
+     * Sets the Normalizer
+     *
+     * @param oid The Normalizer
+     */
+    public void setNormalizer( Normalizer normalizer )
+    {
+        if ( !isReadOnly )
+        {
+            this.normalizer = normalizer;
+        }
+    }
+
+
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
Tue Aug 25 20:00:33 2009
@@ -107,8 +107,6 @@
     }
     
 
-
-
     /**
      * Inject the registries into this Object, updating the references to
      * other SchemaObject
@@ -153,7 +151,7 @@
 
 
     /**
-     * Set the matchingRule's AttributeType OIDs the MRU applies to. description
+     * Set the matchingRule's AttributeType OIDs the MRU applies to.
      *
      * @param applicableAttributes The AttributeType OIDs list
      */
@@ -164,4 +162,62 @@
             this.applicableAttributeOids = applicableAttributeOids;
         }
     }
+    
+    
+    /**
+     * Set the matchingRule's AttributeType the MRU applies to.
+     *
+     * @param applicableAttributes The AttributeType list
+     */
+    public void setApplicableAttributes( List<AttributeType> applicableAttributes )
+    {
+        if ( !isReadOnly )
+        {
+            this.applicableAttributes = applicableAttributes;
+            
+            // update the OIDS now
+            applicableAttributeOids.clear();
+            
+            for ( AttributeType at : applicableAttributes )
+            {
+                applicableAttributeOids.add( at.getOid() );
+            }
+        }
+    }
+    
+    
+    /**
+     * Add a matchingRule's AttributeType OIDs the MRU applies to.
+     *
+     * @param oid A matchingRule's AttributeType OIDs the MRU applies to
+     */
+    public void addApplicableAttributeOids( String oid )
+    {
+        if ( !isReadOnly )
+        {
+            if ( !applicableAttributeOids.contains( oid ) )
+            {
+                applicableAttributeOids.add( oid );
+            }
+        }
+    }
+
+
+    /**
+     * Add a matchingRule's AttributeType the MRU applies to.
+     *
+     * @param oid A matchingRule's AttributeType the MRU applies to
+     */
+    public void addApplicableAttribute( AttributeType attributeType )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! applicableAttributeOids.contains( attributeType.getOid() ) )
+            {
+                applicableAttributes.add( attributeType );
+                applicableAttributeOids.add( attributeType.getOid() );
+            }
+        }
+    }
+    
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/NameForm.java
Tue Aug 25 20:00:33 2009
@@ -202,7 +202,7 @@
      * 
      * @param structuralObjectClass the structural object class to set
      */
-    public void setStructuralObjectClass( String structuralObjectClassOid )
+    public void setStructuralObjectClassOid( String structuralObjectClassOid )
     {
         if ( !isReadOnly )
         {
@@ -212,6 +212,21 @@
 
 
     /**
+     * Sets the structural object class this rule applies to
+     * 
+     * @param structuralObjectClass the structural object class to set
+     */
+    public void setStructuralObjectClass( ObjectClass structuralObjectClass )
+    {
+        if ( !isReadOnly )
+        {
+            this.structuralObjectClass = structuralObjectClass;
+            this.structuralObjectClassOid = structuralObjectClass.getOid();
+        }
+    }
+
+
+    /**
      * Gets all the AttributeTypes OIDs of the attributes this NameForm specifies as
      * having to be used in the given objectClass for naming: as part of the
      * Rdn.
@@ -252,7 +267,29 @@
         }
     }
 
+    
+    /**
+     * Sets the list of required AttributeTypes
+     *
+     * @param mayAttributeTypes the list of required AttributeTypes
+     */
+    public void setMustAttributeTypes( List<AttributeType> mustAttributeTypes )
+    {
+        if ( !isReadOnly )
+        {
+            this.mustAttributeTypes = mustAttributeTypes;
+            
+            // update the OIDS now
+            mustAttributeTypeOids.clear();
+            
+            for ( AttributeType may : mustAttributeTypes )
+            {
+                mustAttributeTypeOids.add( may.getOid() );
+            }
+        }
+    }
 
+    
     /**
      * Add a required AttributeType OID
      *
@@ -266,6 +303,24 @@
         }
     }
 
+
+    /**
+     * Add a required AttributeType
+     *
+     * @param attributeType The attributeType
+     */
+    public void addMustAttributeTypes( AttributeType attributeType )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! mustAttributeTypeOids.contains( attributeType.getOid() ) )
+            {
+                mustAttributeTypes.add( attributeType );
+                mustAttributeTypeOids.add( attributeType.getOid() );
+            }
+        }
+    }
+    
     
     /**
      * Gets all the AttributeTypes OIDs of the attribute this NameForm specifies as
@@ -310,7 +365,29 @@
     
     
     /**
-     * Add an allowed AttribyuteType
+     * Sets the list of allowed AttributeTypes
+     *
+     * @param mayAttributeTypes the list of allowed AttributeTypes
+     */
+    public void setMayAttributeTypes( List<AttributeType> mayAttributeTypes )
+    {
+        if ( !isReadOnly )
+        {
+            this.mayAttributeTypes = mayAttributeTypes;
+            
+            // update the OIDS now
+            mayAttributeTypeOids.clear();
+            
+            for ( AttributeType may : mayAttributeTypes )
+            {
+                mayAttributeTypeOids.add( may.getOid() );
+            }
+        }
+    }
+    
+    
+    /**
+     * Add an allowed AttributeType
      *
      * @param oid The attributeType oid
      */
@@ -321,4 +398,22 @@
             mayAttributeTypeOids.add( oid );
         }
     }
+
+
+    /**
+     * Add an allowed AttributeType
+     *
+     * @param attributeType The attributeType
+     */
+    public void addMayAttributeTypes( AttributeType attributeType )
+    {
+        if ( !isReadOnly )
+        {
+            if ( ! mayAttributeTypeOids.contains( attributeType.getOid() ) )
+            {
+                mayAttributeTypes.add( attributeType );
+                mayAttributeTypeOids.add( attributeType.getOid() );
+            }
+        }
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/AttributeTypeDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/AttributeTypeDescriptionSchemaParser.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/AttributeTypeDescriptionSchemaParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/AttributeTypeDescriptionSchemaParser.java
Tue Aug 25 20:00:33 2009
@@ -22,6 +22,10 @@
 
 import java.text.ParseException;
 
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 import antlr.RecognitionException;
 import antlr.TokenStreamException;
@@ -36,6 +40,8 @@
  */
 public class AttributeTypeDescriptionSchemaParser extends AbstractSchemaParser
 {
+    /** The LoggerFactory used by this class */
+    protected static final Logger LOG = LoggerFactory.getLogger( AttributeTypeDescriptionSchemaParser.class
);
 
     /**
      * Creates a schema parser instance.
@@ -78,12 +84,13 @@
      * @return the parsed AttributeTypeDescription bean
      * @throws ParseException if there are any recognition errors (bad syntax)
      */
-    public synchronized AttributeTypeDescription parseAttributeTypeDescription( String attributeTypeDescription
)
+    public synchronized AttributeType parseAttributeTypeDescription( String attributeTypeDescription
)
         throws ParseException
     {
 
         if ( attributeTypeDescription == null )
         {
+            LOG.error( "Cannot parse a null AttributeType" );
             throw new ParseException( "Null", 0 );
         }
 
@@ -91,36 +98,43 @@
 
         try
         {
-            AttributeTypeDescription atd = parser.attributeTypeDescription();
-            return atd;
+            AttributeType attributeType = parser.attributeTypeDescription();
+            return attributeType;
         }
         catch ( RecognitionException re )
         {
-            String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription;
-            msg += "\nAntlr message: " + re.getMessage();
-            msg += "\nAntlr column: " + re.getColumn();
+            String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription
+
+                "\nAntlr message: " + re.getMessage() +
+                "\nAntlr column: " + re.getColumn();
+            LOG.error( msg );
             throw new ParseException( msg, re.getColumn() );
         }
         catch ( TokenStreamRecognitionException tsre )
         {
-            String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription;
-            msg += "\nAntlr message: " + tsre.getMessage();
+            String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription
+
+                "\nAntlr message: " + tsre.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
         catch ( TokenStreamException tse )
         {
-            String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription;
-            msg += "\nAntlr message: " + tse.getMessage();
+            String msg = "Parser failure on attribute type description:\n\t" + attributeTypeDescription
+
+                "\nAntlr message: " + tse.getMessage();
+            LOG.error( msg );
             throw new ParseException( msg, 0 );
         }
 
     }
 
 
-    public AbstractSchemaDescription parse( String schemaDescription ) throws ParseException
+    /**
+     * Parses a AttributeType description
+     * 
+     * @param The AttributeType description to parse
+     * @return An instance of AttributeType
+     */
+    public AttributeType parse( String schemaDescription ) throws ParseException
     {
         return parseAttributeTypeDescription( schemaDescription );
     }
-
-
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/DITContentRuleDescriptionSchemaParser.java
Tue Aug 25 20:00:33 2009
@@ -42,7 +42,6 @@
     /** The LoggerFactory used by this class */
     protected static final Logger LOG = LoggerFactory.getLogger( DITContentRuleDescriptionSchemaParser.class
);
 
-
     /**
      * Creates a schema parser instance.
      */
@@ -117,5 +116,4 @@
     {
         return parseDITContentRuleDescription( schemaDescription );
     }
-
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/parsers/ParserDescriptionUtils.java
Tue Aug 25 20:00:33 2009
@@ -22,6 +22,7 @@
 
 import java.util.List;
 
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
 import org.apache.directory.shared.ldap.schema.LoadableSchemaObject;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -102,70 +103,70 @@
      * @param atd1 the second attributeType description to compare
      * @return true if both attributeType descriptions match exactly, false otherwise
      */
-    public static boolean attributeTypesMatch( AttributeTypeDescription atd0, AttributeTypeDescription
atd1 )
+    public static boolean attributeTypesMatch( AttributeType at0, AttributeType at1 )
     {
         // compare all common description parameters
-        if ( ! descriptionsMatch( atd0, atd1 ) )
+        if ( ! descriptionsMatch( at0, at1 ) )
         {
             return false;
         }
 
         // check that the same super type is being used for both attributes
-        if ( ! atd0.getSuperType().equals( atd1.getSuperType() ) )
+        if ( ! at0.getSupOid().equals( at1.getSupOid() ) )
         {
             return false;
         }
         
         // check that the same matchingRule is used by both ATs for EQUALITY
-        if ( ! atd0.getEqualityMatchingRule().equals( atd1.getEqualityMatchingRule() ) )
+        if ( ! at0.getEqualityOid().equals( at1.getEqualityOid() ) )
         {
             return false;
         }
         
         // check that the same matchingRule is used by both ATs for SUBSTRING
-        if ( ! atd0.getSubstringsMatchingRule().equals( atd1.getSubstringsMatchingRule()
) )
+        if ( ! at0.getSubstrOid().equals( at1.getSubstrOid() ) )
         {
             return false;
         }
         
         // check that the same matchingRule is used by both ATs for ORDERING
-        if ( ! atd0.getOrderingMatchingRule().equals( atd1.getOrderingMatchingRule() ) )
+        if ( ! at0.getOrderingOid().equals( at1.getOrderingOid() ) )
         {
             return false;
         }
         
         // check that the same syntax is used by both ATs
-        if ( ! atd0.getSyntax().equals( atd1.getSyntax() ) )
+        if ( ! at0.getSyntaxOid().equals( at1.getSyntaxOid() ) )
         {
             return false;
         }
         
         // check that the syntax length constraint is the same for both
-        if ( atd0.getSyntaxLength() != atd1.getSyntaxLength() )
+        if ( at0.getLength() != at1.getLength() )
         {
             return false;
         }
         
         // check that the ATs have the same single valued flag value
-        if ( atd0.isSingleValued() != atd1.isSingleValued() )
+        if ( at0.isSingleValue() != at1.isSingleValue() )
         {
             return false;
         }
         
         // check that the ATs have the same collective flag value
-        if ( atd0.isCollective() != atd1.isCollective() )
+        if ( at0.isCollective() != at1.isCollective() )
         {
             return false;
         }
         
         // check that the ATs have the same user modifiable flag value
-        if ( atd0.isUserModifiable() != atd1.isUserModifiable() )
+        if ( at0.isCanUserModify() != at1.isCanUserModify() )
         {
             return false;
         }
         
         // check that the ATs have the same USAGE
-        if ( atd0.getUsage() != atd1.getUsage() )
+        if ( at0.getUsage() != at1.getUsage() )
         {
             return false;
         }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java?rev=807786&r1=807785&r2=807786&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
Tue Aug 25 20:00:33 2009
@@ -27,7 +27,6 @@
 import org.apache.directory.shared.ldap.schema.DITContentRule;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 import org.apache.directory.shared.ldap.schema.SchemaObjectType;
-import org.apache.directory.shared.ldap.schema.parsers.DITContentRuleDescription;
 import org.apache.directory.shared.ldap.schema.parsers.NormalizerDescription;
 
 



Mime
View raw message