directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r979346 - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/ shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/ shared/trunk/i18n/src/main/resources/org/apache/directory/shared...
Date Mon, 26 Jul 2010 16:27:38 GMT
Author: elecharny
Date: Mon Jul 26 16:27:37 2010
New Revision: 979346

URL: http://svn.apache.org/viewvc?rev=979346&view=rev
Log:
Fix for DIRSERVER-1529 and DIRSERVER-1530

Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
    directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
    directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java?rev=979346&r1=979345&r2=979346&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/collective/CollectiveAttributeServiceIT.java
Mon Jul 26 16:27:37 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.core.collective;
 
@@ -64,23 +64,23 @@ import org.junit.runner.RunWith;
 public class CollectiveAttributeServiceIT extends AbstractLdapTestUnit
 {
     private static LdapConnection connection;
-    
+
     private Entry getTestEntry( String dn, String cn ) throws LdapLdifException, LdapException
     {
-        Entry subentry = LdifUtils.createEntry( 
-            new DN( dn ), 
+        Entry subentry = LdifUtils.createEntry(
+            new DN( dn ),
             "objectClass: top",
             "objectClass: person",
             "cn", cn ,
             "sn: testentry" );
-        
+
         return subentry;
     }
 
 
     private Entry getTestSubentry( String dn )  throws LdapLdifException, LdapException
     {
-        Entry subentry = LdifUtils.createEntry( 
+        Entry subentry = LdifUtils.createEntry(
             new DN( dn ),
             "objectClass: top",
             "objectClass: subentry",
@@ -88,14 +88,14 @@ public class CollectiveAttributeServiceI
             "c-ou: configuration",
             "subtreeSpecification: { base \"ou=configuration\" }",
             "cn: testsubentry" );
-        
+
         return subentry;
     }
 
 
     private Entry getTestSubentry2( String dn ) throws LdapLdifException, LdapException
     {
-        Entry subentry = LdifUtils.createEntry( 
+        Entry subentry = LdifUtils.createEntry(
             new DN( dn ),
             "objectClass: top",
             "objectClass: subentry",
@@ -103,14 +103,14 @@ public class CollectiveAttributeServiceI
             "c-ou: configuration2",
             "subtreeSpecification: { base \"ou=configuration\" }",
             "cn: testsubentry2" );
-        
+
         return subentry;
     }
 
 
     private Entry getTestSubentry3( String dn ) throws LdapLdifException, LdapException
     {
-        Entry subentry = LdifUtils.createEntry( 
+        Entry subentry = LdifUtils.createEntry(
             new DN( dn ),
             "objectClass: top",
             "objectClass: subentry",
@@ -118,7 +118,7 @@ public class CollectiveAttributeServiceI
             "c-st: FL",
             "subtreeSpecification: { base \"ou=configuration\" }",
             "cn: testsubentry3" );
-        
+
         return subentry;
     }
 
@@ -126,8 +126,8 @@ public class CollectiveAttributeServiceI
     private void addAdministrativeRole( String role ) throws Exception
     {
         EntryAttribute attribute = new DefaultEntryAttribute( "administrativeRole", role
);
-        
-        connection.modify( new DN( "ou=system" ), new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
attribute ) );
+
+        connection.modify( "ou=system", new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
attribute ) );
     }
 
 
@@ -135,13 +135,13 @@ public class CollectiveAttributeServiceI
     {
         Map<String, Entry> resultMap = new HashMap<String, Entry>();
 
-        Cursor<SearchResponse> cursor = 
+        Cursor<SearchResponse> cursor =
             connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "+",
"*" );
-        
+
         while ( cursor.next() )
         {
             SearchResponse result = cursor.get();
-            
+
             if ( result instanceof SearchResultEntry )
             {
                 Entry entry = ((SearchResultEntry)result).getEntry();
@@ -157,13 +157,13 @@ public class CollectiveAttributeServiceI
     {
         Map<String, Entry> resultMap = new HashMap<String, Entry>();
 
-        Cursor<SearchResponse> cursor = 
+        Cursor<SearchResponse> cursor =
             connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "cn"
);
-        
+
         while ( cursor.next() )
         {
             SearchResponse result = cursor.get();
-            
+
             if ( result instanceof SearchResultEntry )
             {
                 Entry entry = ((SearchResultEntry)result).getEntry();
@@ -173,19 +173,19 @@ public class CollectiveAttributeServiceI
 
         return resultMap;
     }
-    
-    
+
+
     private Map<String, Entry> getAllEntriesCollectiveAttributesOnly() throws Exception
     {
         Map<String, Entry> resultMap = new HashMap<String, Entry>();
 
-        Cursor<SearchResponse> cursor = 
+        Cursor<SearchResponse> cursor =
             connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "c-ou",
"c-st" );
-        
+
         while ( cursor.next() )
         {
             SearchResponse result = cursor.get();
-            
+
             if ( result instanceof SearchResultEntry )
             {
                 Entry entry = ((SearchResultEntry)result).getEntry();
@@ -196,20 +196,20 @@ public class CollectiveAttributeServiceI
         return resultMap;
     }
 
-    
+
     @Before
     public void init() throws Exception
     {
         connection = IntegrationUtils.getAdminConnection( service );
     }
-    
+
 
     @After
     public void shutdown() throws Exception
     {
         connection.close();
     }
-    
+
 
     @Test
     public void testLookup() throws Exception
@@ -243,9 +243,9 @@ public class CollectiveAttributeServiceI
         // -------------------------------------------------------------------
         // now modify entries included by the subentry to have collectiveExclusions
         // -------------------------------------------------------------------
-        Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,

+        Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultEntryAttribute( "collectiveExclusions", "c-ou" ) );
-        connection.modify( new DN( "ou=services,ou=configuration, ou=system" ), modification
);
+        connection.modify( "ou=services,ou=configuration, ou=system", modification );
 
         // entry should not show the c-ou collective attribute anymore
         response = connection.lookup( "ou=services,ou=configuration,ou=system" );
@@ -283,18 +283,18 @@ public class CollectiveAttributeServiceI
         response = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "c-ou"
);
         entry = ((SearchResultEntry)response).getEntry();
         c_ou = entry.get( "c-ou" );
-        
+
         assertNotNull( "a collective c-ou attribute should be present", c_ou );
         assertTrue( c_ou.contains( "configuration" ) );
         assertTrue( c_ou.contains( "configuration2" ) );
-        
+
         // unspecify the collective attribute in the returning attribute list
         response = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "objectClass"
);
         entry = ((SearchResultEntry)response).getEntry();
         c_ou = entry.get( "c-ou" );
 
         assertNull( "a collective c-ou attribute should not be present", c_ou );
-        
+
         // -------------------------------------------------------------------
         // now add the subentry for the c-st collective attribute
         // -------------------------------------------------------------------
@@ -316,7 +316,7 @@ public class CollectiveAttributeServiceI
         assertNotNull( "a collective c-ou attribute should be present", c_ou );
         assertTrue( c_ou.contains( "configuration" ) );
         assertTrue( c_ou.contains( "configuration2" ) );
-        
+
         c_st = entry.get( "c-st" );
         assertNotNull( "a collective c-st attribute should be present", c_st );
         assertTrue( c_st.contains( "FL" ) );
@@ -324,9 +324,9 @@ public class CollectiveAttributeServiceI
         // -------------------------------------------------------------------
         // now modify an entry to exclude all collective attributes
         // -------------------------------------------------------------------
-        modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,

+        modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
             new DefaultEntryAttribute( "collectiveExclusions", "excludeAllCollectiveAttributes"
) );
-        connection.modify( new DN( "ou=interceptors,ou=configuration, ou=system" ), modification
);
+        connection.modify( "ou=interceptors,ou=configuration, ou=system" , modification );
 
         // none of the attributes should appear any longer
         response = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );
@@ -339,7 +339,7 @@ public class CollectiveAttributeServiceI
         }
 
         c_st = entry.get( "c-st" );
-        
+
         if ( c_st != null )
         {
             assertEquals( "the c-st collective attribute should not be present", 0, c_st.size()
);
@@ -365,16 +365,34 @@ public class CollectiveAttributeServiceI
         assertNotNull( "a collective c-ou attribute should be present", c_ou );
         assertEquals( "configuration", c_ou.getString() );
 
+        // -------------------------------------------------------------------
+        // Test searching for subtypes
+        // -------------------------------------------------------------------
+        Cursor<SearchResponse> responses = connection.search( "ou=services,ou=configuration,ou=system",
"(ObjectClass=*)",
+            SearchScope.OBJECT, "ou" );
+
+        while ( responses.next() )
+        {
+            SearchResultEntry resultEntry = (SearchResultEntry)responses.get();
+            entry = resultEntry.getEntry();
+
+            assertEquals( 2, entry.size() );
+            assertTrue( entry.containsAttribute( "ou" ) );
+            assertTrue( entry.containsAttribute( "c-ou" ) );
+            assertTrue( entry.contains( "ou", "services" ) );
+            assertTrue( entry.contains( "c-ou", "configuration" ) );
+        }
+
         // ------------------------------------------------------------------
-        // test an entry that should show the collective attribute c-ou, 
+        // test an entry that should show the collective attribute c-ou,
         // but restrict returned attributes to c-ou and c-st
         // ------------------------------------------------------------------
         entries = getAllEntriesCollectiveAttributesOnly();
         entry = entries.get( "ou=services,ou=configuration,ou=system" );
         c_ou = entry.get( "c-ou" );
         assertNotNull( "a collective c-ou attribute should be present", c_ou );
-        assertEquals( "configuration", c_ou.getString() );   
-        
+        assertEquals( "configuration", c_ou.getString() );
+
         // -------------------------------------------------------------------
         // test an entry that should not show the collective attribute
         // -------------------------------------------------------------------
@@ -385,16 +403,16 @@ public class CollectiveAttributeServiceI
         // -------------------------------------------------------------------
         // now modify entries included by the subentry to have collectiveExclusions
         // -------------------------------------------------------------------
-        Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,

+        Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
             new DefaultEntryAttribute( "collectiveExclusions", "c-ou" ) );
-        connection.modify( new DN( "ou=services,ou=configuration, ou=system" ), modification
);
+        connection.modify( "ou=services,ou=configuration, ou=system", modification );
 
         entries = getAllEntries();
 
         // entry should not show the c-ou collective attribute anymore
         entry = entries.get( "ou=services,ou=configuration,ou=system" );
         c_ou = entry.get( "c-ou" );
-        
+
         if ( c_ou != null )
         {
             assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size()
);
@@ -406,7 +424,7 @@ public class CollectiveAttributeServiceI
 
         entry = entries.get( "ou=services,ou=configuration,ou=system" );
         c_ou = entry.get( "c-ou" );
-        
+
         if ( c_ou != null )
         {
             assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size()
);
@@ -445,23 +463,23 @@ public class CollectiveAttributeServiceI
         // -------------------------------------------------------------------
         // now modify an entry to exclude all collective attributes
         // -------------------------------------------------------------------
-        modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,

+        modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
             new DefaultEntryAttribute( "collectiveExclusions", "excludeAllCollectiveAttributes"
) );
-        connection.modify( new DN( "ou=interceptors,ou=configuration, ou=system" ), modification
);
+        connection.modify( "ou=interceptors,ou=configuration, ou=system", modification );
 
         entries = getAllEntries();
 
         // none of the attributes should appear any longer
         entry = entries.get( "ou=interceptors,ou=configuration,ou=system" );
         c_ou = entry.get( "c-ou" );
-        
+
         if ( c_ou != null )
         {
             assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size()
);
         }
-        
+
         c_st = entry.get( "c-st" );
-        
+
         if ( c_st != null )
         {
             assertEquals( "the c-st collective attribute should not be present", 0, c_st.size()
);
@@ -484,34 +502,34 @@ public class CollectiveAttributeServiceI
         assertNull( c_ou );
         assertNull( c_st );
     }
-    
-    
+
+
     @Test
     public void testAddRegularEntryWithCollectiveAttribute() throws Exception
     {
         Entry entry = getTestEntry( "cn=Ersin Er,ou=system", "Ersin Er" );
         entry.put( "c-l", "Turkiye" );
-        
+
         AddResponse response = connection.add( entry );
-        
+
         assertEquals( ResultCodeEnum.OBJECT_CLASS_VIOLATION, response.getLdapResult().getResultCode()
);
     }
-    
-    
+
+
     @Test
     public void testModifyRegularEntryAddingCollectiveAttribute() throws Exception
     {
         Entry entry = getTestEntry( "cn=Ersin Er,ou=system", "Ersin Er" );
         connection.add( entry );
-        
-        ModifyResponse response = connection.modify( new DN( "cn=Ersin Er,ou=system" ), 
-            new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, 
+
+        ModifyResponse response = connection.modify( "cn=Ersin Er,ou=system",
+            new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
                 new DefaultEntryAttribute( "c-l", "Turkiye" ) ) );
-        
+
         assertEquals( ResultCodeEnum.OBJECT_CLASS_VIOLATION, response.getLdapResult().getResultCode()
);
     }
-    
-    
+
+
     @Test
     public void testPolymorphicReturnAttrLookup() throws Exception
     {
@@ -521,12 +539,12 @@ public class CollectiveAttributeServiceI
         addAdministrativeRole( "collectiveAttributeSpecificArea" );
         Entry subentry = getTestSubentry( "cn=testsubentry,ou=system" );
         connection.add( subentry );
-    
+
         // request the collective attribute's super type specifically
         SearchResponse response = connection.lookup( "ou=interceptors,ou=configuration,ou=system",
"ou" );
-        
+
         Entry entry = ((SearchResultEntry)response).getEntry();
-        
+
         EntryAttribute c_ou = entry.get( "c-ou" );
         assertNotNull( "a collective c-ou attribute should be present", c_ou );
         assertTrue( c_ou.contains( "configuration" ) );

Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=979346&r1=979345&r2=979346&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Mon
Jul 26 16:27:37 2010
@@ -620,6 +620,10 @@ public enum I18n
     ERR_04479_INVALID_SYNTAX_VALUE( "ERR_04479_INVALID_SYNTAX_VALUE" ),
     ERR_04480_END_OF_STREAM( "ERR_04480_END_OF_STREAM" ),
     ERR_04481_ENTRY_NULL_VALUE( "ERR_04481_ENTRY_NULL_VALUE" ),
+    ERR_04482_CANNOT_SUBTYPE_COLLECTIVE( "ERR_04482_CANNOT_SUBTYPE_COLLECTIVE" ),
+    ERR_04483_COLLECTIVE_NOT_MULTI_VALUED( "ERR_04483_COLLECTIVE_NOT_MULTI_VALUED" ),
+    ERR_04484_COLLECTIVE_NOT_ALLOWED_IN_MUST( "ERR_04484_COLLECTIVE_NOT_ALLOWED_IN_MUST"
),
+    ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY( "ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY" ),
 
     // ldap-constants
     ERR_05001( "ERR_05001" ),
@@ -779,7 +783,7 @@ public enum I18n
     ERR_12085( "ERR_12085" ),
     ERR_12086( "ERR_12086" ),
     ERR_12087( "ERR_12087" );
-    
+
     /** The error code */
     private String errorCode;
 

Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=979346&r1=979345&r2=979346&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
(original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
Mon Jul 26 16:27:37 2010
@@ -604,6 +604,10 @@ ERR_04478_NO_VALUE_NOT_ALLOWED=Cannot cr
 ERR_04479_INVALID_SYNTAX_VALUE= The value ''{0}'' does not respect the AttributeType ''{1}''
syntax
 ERR_04480_END_OF_STREAM=End of stream
 ERR_04481_ENTRY_NULL_VALUE=Entry can't be null
+ERR_04482_CANNOT_SUBTYPE_COLLECTIVE=The Collective Attribute ({0}) cannot be subtyped ({1})
+ERR_04483_COLLECTIVE_NOT_MULTI_VALUED=The Collective Attribute ({0}) cannot be single valued
+ERR_04484_COLLECTIVE_NOT_ALLOWED_IN_MUST=The Collective Attribute ({0}) cannot be added in
the MUST list of the {1} ObjectClass
+ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY=The Collective Attribute ({0}) cannot be added in
the MAY list of the {1} ObjectClass
 
 # ldap-constants
 ERR_05001=Unknown AuthenticationLevel {0}

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=979346&r1=979345&r2=979346&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
Mon Jul 26 16:27:37 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.shared.ldap.schema;
 
@@ -42,12 +42,12 @@ import org.slf4j.LoggerFactory;
  * <p>
  * According to ldapbis [MODELS]:
  * </p>
- * 
+ *
  * <pre>
  *  4.1.2. Attribute Types
- *  
+ *
  *    Attribute Type definitions are written according to the ABNF:
- *  
+ *
  *      AttributeTypeDescription = LPAREN WSP
  *          numericoid                   ; object identifier
  *          [ SP &quot;NAME&quot; SP qdescrs ]     ; short names (descriptors)
@@ -63,12 +63,12 @@ import org.slf4j.LoggerFactory;
  *          [ SP &quot;NO-USER-MODIFICATION&quot; ]; not user modifiable
  *          [ SP &quot;USAGE&quot; SP usage ]      ; usage
  *          extensions WSP RPAREN        ; extensions
- *  
+ *
  *      usage = &quot;userApplications&quot;     / ; user
  *              &quot;directoryOperation&quot;   / ; directory operational
  *              &quot;distributedOperation&quot; / ; DSA-shared operational
  *              &quot;dSAOperation&quot;           ; DSA-specific operational
- *  
+ *
  *    where:
  *      [numericoid] is object identifier assigned to this attribute type;
  *      NAME [qdescrs] are short names (descriptors) identifying this
@@ -85,46 +85,46 @@ import org.slf4j.LoggerFactory;
  *          modifiable;
  *      USAGE indicates the application of this attribute type; and
  *      [extensions] describe extensions.
- *  
+ *
  *    Each attribute type description must contain at least one of the SUP
  *    or SYNTAX fields.
- *  
+ *
  *    Usage of userApplications, the default, indicates that attributes of
  *    this type represent user information.  That is, they are user
  *    attributes.
- *  
+ *
  *    COLLECTIVE requires usage userApplications.  Use of collective
  *    attribute types in LDAP is not discussed in this technical
  *    specification.
- *  
+ *
  *    A usage of directoryOperation, distributedOperation, or dSAOperation
  *    indicates that attributes of this type represent operational and/or
  *    administrative information.  That is, they are operational attributes.
- *  
+ *
  *    directoryOperation usage indicates that the attribute of this type is
  *    a directory operational attribute.  distributedOperation usage
  *    indicates that the attribute of this DSA-shared usage operational
  *    attribute.  dSAOperation usage indicates that the attribute of this
  *    type is a DSA-specific operational attribute.
- *  
+ *
  *    NO-USER-MODIFICATION requires an operational usage.
- *  
+ *
  *    Note that the [AttributeTypeDescription] does not list the matching
  *    rules which can be used with that attribute type in an extensibleMatch
  *    search filter.  This is done using the 'matchingRuleUse' attribute
  *    described in Section 4.1.4.
- *  
+ *
  *    This document refines the schema description of X.501 by requiring
  *    that the SYNTAX field in an [AttributeTypeDescription] be a string
  *    representation of an object identifier for the LDAP string syntax
  *    definition with an optional indication of the suggested minimum bound
  *    of a value of this attribute.
- *  
+ *
  *    A suggested minimum upper bound on the number of characters in a value
  *    with a string-based syntax, or the number of bytes in a value for all
  *    other syntaxes, may be indicated by appending this bound count inside
  *    of curly braces following the syntax's OBJECT IDENTIFIER in an
- *  
+ *
  *    Attribute Type Description.  This bound is not part of the syntax name
  *    itself.  For instance, &quot;1.3.6.4.1.1466.0{64}&quot; suggests that server
  *    implementations should allow a string to be 64 characters long,
@@ -132,7 +132,7 @@ import org.slf4j.LoggerFactory;
  *    of the Directory String syntax may be encoded in more than one octet
  *    since UTF-8 is a variable-length encoding.
  * </pre>
- * 
+ *
  * @see <a href="http://www.faqs.org/rfcs/rfc2252.html">RFC 2252 Section 4.2</a>
  * @see <a
  *      href="http://www.ietf.org/internet-drafts/draft-ietf-ldapbis-models-11.txt">
@@ -196,7 +196,7 @@ public class AttributeType extends Abstr
 
     /**
      * Creates a AttributeType object using a unique OID.
-     * 
+     *
      * @param oid the OID for this AttributeType
      */
     public AttributeType( String oid )
@@ -235,6 +235,17 @@ public class AttributeType extends Abstr
 
             if ( superior != null )
             {
+                // a special case : if the superior is collective, this is an error
+                if ( superior.isCollective )
+                {
+                    String msg = I18n.err( I18n.ERR_04482_CANNOT_SUBTYPE_COLLECTIVE, superior,
getName() );
+
+                    Throwable error = new LdapProtocolErrorException( msg );
+                    errors.add( error );
+                    LOG.info( msg );
+                    return false;
+                }
+
                 this.superior = superior;
 
                 // Recursively update the superior if not already done. We don't recurse
@@ -560,7 +571,7 @@ public class AttributeType extends Abstr
      */
     private void checkCollective( List<Throwable> errors )
     {
-        if ( superior != null && superior.isCollective() )
+        if ( ( superior != null ) && superior.isCollective() )
         {
             // An AttributeType will be collective if its superior is collective
             this.isCollective = true;
@@ -575,18 +586,28 @@ public class AttributeType extends Abstr
             errors.add( error );
             LOG.info( msg );
         }
+
+        if ( isCollective() && isSingleValued() )
+        {
+            // A collective attribute must be multi-valued
+            String msg = I18n.err( I18n.ERR_04483_COLLECTIVE_NOT_MULTI_VALUED, getName()
);
+
+            Throwable error = new LdapProtocolErrorException( msg );
+            errors.add( error );
+            LOG.info( msg );
+        }
     }
 
 
     /**
      * Inject the attributeType into the registries, updating the references to
      * other SchemaObject.
-     * 
-     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX), 
+     *
+     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX),
      * an exception is thrown.
      *
      * @param registries The Registries
-     * @exception If the AttributeType is not valid 
+     * @exception If the AttributeType is not valid
      */
     public void addToRegistries( List<Throwable> errors, Registries registries ) throws
LdapException
     {
@@ -626,7 +647,7 @@ public class AttributeType extends Abstr
             attributeTypeRegistry.registerDescendants( this, superior );
 
             /**
-             * Add the AT references (using and usedBy) : 
+             * Add the AT references (using and usedBy) :
              * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
              * AT -> S
              * AT -> AT
@@ -662,12 +683,12 @@ public class AttributeType extends Abstr
     /**
      * Remove the attributeType from the registries, updating the references to
      * other SchemaObject.
-     * 
-     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX), 
+     *
+     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR,
SYNTAX),
      * an exception is thrown.
      *
      * @param registries The Registries
-     * @exception If the AttributeType is not valid 
+     * @exception If the AttributeType is not valid
      */
     public void removeFromRegistries( List<Throwable> errors, Registries registries
) throws LdapException
     {
@@ -682,7 +703,7 @@ public class AttributeType extends Abstr
             attributeTypeRegistry.unregisterDescendants( this, superior );
 
             /**
-             * Remove the AT references (using and usedBy) : 
+             * Remove the AT references (using and usedBy) :
              * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
              * AT -> S
              * AT -> AT
@@ -717,7 +738,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets whether or not this AttributeType is single-valued.
-     * 
+     *
      * @return true if only one value can exist for this AttributeType, false
      *         otherwise
      */
@@ -748,7 +769,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets whether or not this AttributeType can be modified by a user.
-     * 
+     *
      * @return true if users can modify it, false if only the directory can.
      */
     public boolean isUserModifiable()
@@ -778,7 +799,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets whether or not this AttributeType is a collective attribute.
-     * 
+     *
      * @return true if the attribute is collective, false otherwise
      */
     public boolean isCollective()
@@ -824,7 +845,7 @@ public class AttributeType extends Abstr
 
     /**
      * Determines the usage for this AttributeType.
-     * 
+     *
      * @return a type safe UsageEnum
      */
     public UsageEnum getUsage()
@@ -880,7 +901,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets a length limit for this AttributeType.
-     * 
+     *
      * @return the length of the attribute
      */
     public long getSyntaxLength()
@@ -892,7 +913,7 @@ public class AttributeType extends Abstr
     /**
      * Sets the length limit of this AttributeType based on its associated
      * syntax.
-     * 
+     *
      * @param length the new length to set
      */
     public void setSyntaxLength( long length )
@@ -911,7 +932,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the the superior AttributeType of this AttributeType.
-     * 
+     *
      * @return the superior AttributeType for this AttributeType
      */
     public AttributeType getSuperior()
@@ -922,7 +943,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the OID of the superior AttributeType for this AttributeType.
-     * 
+     *
      * @return The OID of the superior AttributeType for this AttributeType.
      */
     public String getSuperiorOid()
@@ -933,7 +954,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Name of the superior AttributeType for this AttributeType.
-     * 
+     *
      * @return The Name of the superior AttributeType for this AttributeType.
      */
     public String getSuperiorName()
@@ -1026,7 +1047,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Syntax for this AttributeType's values.
-     * 
+     *
      * @return the value syntax
      */
     public LdapSyntax getSyntax()
@@ -1037,7 +1058,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Syntax name for this AttributeType's values.
-     * 
+     *
      * @return the value syntax name
      */
     public String getSyntaxName()
@@ -1055,7 +1076,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Syntax OID for this AttributeType's values.
-     * 
+     *
      * @return the value syntax's OID
      */
     public String getSyntaxOid()
@@ -1122,7 +1143,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the MatchingRule for this AttributeType used for equality matching.
-     * 
+     *
      * @return the equality matching rule
      */
     public MatchingRule getEquality()
@@ -1133,7 +1154,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Equality OID for this AttributeType's values.
-     * 
+     *
      * @return the value Equality's OID
      */
     public String getEqualityOid()
@@ -1144,7 +1165,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Equality Name for this AttributeType's values.
-     * 
+     *
      * @return the value Equality's Name
      */
     public String getEqualityName()
@@ -1218,7 +1239,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the MatchingRule for this AttributeType used for Ordering matching.
-     * 
+     *
      * @return the Ordering matching rule
      */
     public MatchingRule getOrdering()
@@ -1229,7 +1250,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the MatchingRule name for this AttributeType used for Ordering matching.
-     * 
+     *
      * @return the Ordering matching rule name
      */
     public String getOrderingName()
@@ -1247,7 +1268,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Ordering OID for this AttributeType's values.
-     * 
+     *
      * @return the value Equality's OID
      */
     public String getOrderingOid()
@@ -1314,7 +1335,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the MatchingRule for this AttributeType used for Substr matching.
-     * 
+     *
      * @return the Substr matching rule
      */
     public MatchingRule getSubstring()
@@ -1325,7 +1346,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the MatchingRule name for this AttributeType used for Substring matching.
-     * 
+     *
      * @return the Substring matching rule name
      */
     public String getSubstringName()
@@ -1343,7 +1364,7 @@ public class AttributeType extends Abstr
 
     /**
      * Gets the Substr OID for this AttributeType's values.
-     * 
+     *
      * @return the value Substr's OID
      */
     public String getSubstringOid()



Mime
View raw message