directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1664350 - in /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema: ./ parsers/
Date Thu, 05 Mar 2015 14:00:35 GMT
Author: elecharny
Date: Thu Mar  5 14:00:34 2015
New Revision: 1664350

URL: http://svn.apache.org/r1664350
Log:
Fixed the SchemaObject extension key, which should always be considered as case insensitive

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserDescriptionUtils.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java?rev=1664350&r1=1664349&r2=1664350&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/AbstractSchemaObject.java
Thu Mar  5 14:00:34 2015
@@ -477,7 +477,7 @@ public abstract class AbstractSchemaObje
 
 
     /**
-     * @return The SchemaObject extensions, as a Map of [extension, values]
+     * {@inheritDoc}
      */
     public Map<String, List<String>> getExtensions()
     {
@@ -486,6 +486,37 @@ public abstract class AbstractSchemaObje
 
 
     /**
+     * {@inheritDoc}
+     */
+    public boolean hasExtension( String extension )
+    {
+        return extensions.containsKey( Strings.toUpperCase( extension ) );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<String> getExtension( String extension )
+    {
+        String name = Strings.toUpperCase( extension );
+
+        if ( hasExtension( name ) )
+        {
+            for ( String key : extensions.keySet() )
+            {
+                if ( name.equalsIgnoreCase( key ) )
+                {
+                    return extensions.get( key );
+                }
+            }
+        }
+
+        return null;
+    }
+
+
+    /**
      * Add an extension with its values
      * @param key The extension key
      * @param values The associated values
@@ -500,13 +531,13 @@ public abstract class AbstractSchemaObje
         if ( !isReadOnly )
         {
             List<String> valueList = new ArrayList<String>();
-            
+
             for ( String value : values )
             {
                 valueList.add( value );
             }
-            
-            extensions.put( key, valueList );
+
+            extensions.put( Strings.toUpperCase( key ), valueList );
         }
     }
 
@@ -525,7 +556,7 @@ public abstract class AbstractSchemaObje
 
         if ( !isReadOnly )
         {
-            extensions.put( key, values );
+            extensions.put( Strings.toUpperCase( key ), values );
         }
     }
 
@@ -555,7 +586,7 @@ public abstract class AbstractSchemaObje
                     values.add( value );
                 }
 
-                this.extensions.put( entry.getKey(), values );
+                this.extensions.put( Strings.toUpperCase( entry.getKey() ), values );
             }
 
         }
@@ -838,7 +869,7 @@ public abstract class AbstractSchemaObje
 
         for ( String key : original.getExtensions().keySet() )
         {
-            List<String> extensionValues = original.getExtensions().get( key );
+            List<String> extensionValues = original.getExtension( key );
 
             List<String> cloneExtension = new ArrayList<String>();
 
@@ -879,8 +910,8 @@ public abstract class AbstractSchemaObje
         // Clear the names
         names.clear();
     }
-    
-    
+
+
     public void unlock()
     {
         locked = false;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java?rev=1664350&r1=1664349&r2=1664350&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/LdapSyntax.java
Thu Mar  5 14:00:34 2015
@@ -137,12 +137,12 @@ public class LdapSyntax extends Abstract
         }
         else
         {
-            List<String> values = extensions.get( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT
);
+            List<String> values = getExtension( MetaSchemaConstants.X_NOT_HUMAN_READABLE_AT
);
 
             if ( ( values == null ) || ( values.size() == 0 ) )
             {
                 // Default to String if the flag is not set
-                return false;
+                return true;
             }
             else
             {
@@ -184,26 +184,6 @@ public class LdapSyntax extends Abstract
     }
 
 
-    /**
-     * Gets whether or not the Human Readable extension is present in the Syntax.
-     * 
-     * @return true if the syntax contains teh X-NOT-HUMAN-READABLE extension
-     *
-    public boolean hasHumanReadableFlag()
-    {
-        return hasHumanReadableFlag;
-    }
-
-
-    /**
-     * Sets the hasHumanReadableFlag to true if we have a X-NOT-HUMAN-READABLE extension
-     *
-    public void setHasHumanReadableFlag()
-    {
-        hasHumanReadableFlag = true;
-    }
-
-
     /**
      * Gets the SyntaxChecker used to validate values in accordance with this
      * Syntax.

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java?rev=1664350&r1=1664349&r2=1664350&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaObject.java
Thu Mar  5 14:00:34 2015
@@ -219,6 +219,24 @@ public interface SchemaObject
 
 
     /**
+     * Check if a given extension is part of the SchemaObject. Extensions are case insensitive.
+     * 
+     * @param extension The extension we are looking for.
+     * @return <code>true</code> if the extension is present.
+     */
+    boolean hasExtension( String extension );
+
+
+    /**
+     * Get back the values associated with a given extension.
+     * 
+     * @param extension The extension we are looking for.
+     * @return The list of values associated with the extension
+     */
+    List<String> getExtension( String extension );
+
+
+    /**
      * Add an extension with its values
      * @param key The extension key
      * @param values The associated values

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java?rev=1664350&r1=1664349&r2=1664350&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaUtils.java
Thu Mar  5 14:00:34 2015
@@ -364,7 +364,6 @@ public final class SchemaUtils
     // schema object rendering operations
     // ------------------------------------------------------------------------
 
-
     /**
      * Renders the schema extensions into a new StringBuffer.
      *
@@ -418,8 +417,6 @@ public final class SchemaUtils
     }
 
 
-    
-
     /**
      * Returns a String description of a schema. The resulting String format is :
      * <br>
@@ -456,7 +453,7 @@ public final class SchemaUtils
 
     private static String getSchemaName( SchemaObject desc )
     {
-        List<String> values = desc.getExtensions().get( MetaSchemaConstants.X_SCHEMA_AT
);
+        List<String> values = desc.getExtension( MetaSchemaConstants.X_SCHEMA_AT );
 
         if ( values == null || values.size() == 0 )
         {

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java?rev=1664350&r1=1664349&r2=1664350&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/AbstractSchemaParser.java
Thu Mar  5 14:00:34 2015
@@ -232,7 +232,7 @@ public abstract class AbstractSchemaPars
     private void updateSchemaName( SchemaObject schemaObject )
     {
         // Update the Schema if we have the X-SCHEMA extension
-        List<String> schemaExtension = schemaObject.getExtensions().get( MetaSchemaConstants.X_SCHEMA_AT
);
+        List<String> schemaExtension = schemaObject.getExtension( MetaSchemaConstants.X_SCHEMA_AT
);
 
         if ( schemaExtension != null )
         {

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserDescriptionUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserDescriptionUtils.java?rev=1664350&r1=1664349&r2=1664350&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserDescriptionUtils.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/ParserDescriptionUtils.java
Thu Mar  5 14:00:34 2015
@@ -285,8 +285,8 @@ public final class ParserDescriptionUtil
         // check contents and order of extension values must match
         for ( String key : lsd0.getExtensions().keySet() )
         {
-            List<String> values0 = lsd0.getExtensions().get( key );
-            List<String> values1 = lsd1.getExtensions().get( key );
+            List<String> values0 = lsd0.getExtension( key );
+            List<String> values1 = lsd1.getExtension( key );
 
             // if the key is not present in asd1
             if ( values1 == null )



Mime
View raw message