directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1732338 - in /directory/shared/trunk/ldap: client/api/src/main/java/org/apache/directory/ldap/client/api/ model/src/main/java/org/apache/directory/api/ldap/model/name/
Date Thu, 25 Feb 2016 18:35:58 GMT
Author: elecharny
Date: Thu Feb 25 18:35:58 2016
New Revision: 1732338

URL: http://svn.apache.org/viewvc?rev=1732338&view=rev
Log:
o Deal with missing attributes when the schema manager is in relaxed mode

Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java?rev=1732338&r1=1732337&r2=1732338&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdifAnonymizer.java
Thu Feb 25 18:35:58 2016
@@ -419,25 +419,25 @@ public class LdifAnonymizer
             {
                 if ( anonymizer == null )
                 {
-                    anonymizedAva = new Ava( schemaManager, attributeType.getName(), value.getString()
);
+                    anonymizedAva = new Ava( schemaManager, ava.getType(), value.getString()
);
                 }
                 else
                 {
                     Attribute anonymizedAttribute = anonymizer.anonymize( valueMap, valueSet,
attribute );
-                    anonymizedAva = new Ava( schemaManager, attributeType.getName(), anonymizedAttribute.getString()
);
+                    anonymizedAva = new Ava( schemaManager, ava.getType(), anonymizedAttribute.getString()
);
                 }
             }
             else
             {
                 if ( anonymizer == null )
                 {
-                    anonymizedAva = new Ava( schemaManager, attributeType.getName(), value.getBytes()
);
+                    anonymizedAva = new Ava( schemaManager, ava.getType(), value.getBytes()
);
                 }
                 else
                 {
                     Attribute anonymizedAttribute = anonymizer.anonymize( valueMap, valueSet,
attribute );
 
-                    anonymizedAva = new Ava( schemaManager, attributeType.getName(), anonymizedAttribute.getBytes()
);
+                    anonymizedAva = new Ava( schemaManager, ava.getType(), anonymizedAttribute.getBytes()
);
                 }
             }
         }
@@ -445,11 +445,11 @@ public class LdifAnonymizer
         {
             if ( value.isHumanReadable() )
             {
-                anonymizedAva = new Ava( schemaManager, attributeType.getName(), anonymizedValue.getString()
);
+                anonymizedAva = new Ava( schemaManager, ava.getType(), anonymizedValue.getString()
);
             }
             else
             {
-                anonymizedAva = new Ava( schemaManager, attributeType.getName(), anonymizedValue.getBytes()
);
+                anonymizedAva = new Ava( schemaManager, ava.getType(), anonymizedValue.getBytes()
);
             }
         }
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java?rev=1732338&r1=1732337&r2=1732338&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Ava.java
Thu Feb 25 18:35:58 2016
@@ -466,9 +466,17 @@ public class Ava implements Externalizab
             }
             catch ( LdapException le )
             {
-                String message = I18n.err( I18n.ERR_04188 );
-                LOG.error( message );
-                throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message,
le );
+                if ( schemaManager.isRelaxed() )
+                {
+                    // No attribute in the schema, but the schema is relaxed : get out
+                    return;
+                }
+                else
+                {
+                    String message = I18n.err( I18n.ERR_04188 );
+                    LOG.error( message );
+                    throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message,
le );
+                }
             }
 
             if ( this.attributeType == tmpAttributeType )

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java?rev=1732338&r1=1732337&r2=1732338&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/name/Rdn.java
Thu Feb 25 18:35:58 2016
@@ -633,8 +633,11 @@ public class Rdn implements Cloneable, E
                 // Check that the first AVA is not for the same attribute
                 if ( avaType.equals( normalizedType ) )
                 {
-                    throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType
-                        + " is already present in the RDN" );
+                    if ( ava.getValue().equals( value.getValue() ) )
+                    {
+                        throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType
+                            + " is already present in the RDN" );
+                    }
                 }
 
                 // First, create the HashMap,
@@ -654,15 +657,28 @@ public class Rdn implements Cloneable, E
                 // Check that the AT is not already present
                 if ( avaTypes.containsKey( normalizedType ) )
                 {
-                    throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType
-                        + " is already present in the RDN" );
+                    Collection<Ava> atavList = ( Collection<Ava> ) avaTypes.get(
normalizedType );
+                    
+                    if ( atavList.contains( value ) )
+                    {
+                        throw new LdapInvalidDnException( "Invalid RDN: the " + normalizedType
+                            + " is already present in the RDN" );
+                    }
+                    else
+                    {
+                        // Add the value to the list
+                        atavList.add( value );
+                        nbAvas++;
+                    }
+                }
+                else
+                {
+                    // add a new Ava
+                    avas.add( value );
+                    avaTypes.put( normalizedType, value );
+                    nbAvas++;
+                    hashCode();
                 }
-
-                // add a new Ava
-                avas.add( value );
-                avaTypes.put( normalizedType, value );
-                nbAvas++;
-                hashCode();
 
                 break;
         }



Mime
View raw message