directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r411272 - in /directory/releases/shared/0.9.5.1/ldap/src: main/java/org/apache/directory/shared/ldap/codec/ main/java/org/apache/directory/shared/ldap/codec/add/ main/java/org/apache/directory/shared/ldap/codec/modify/ main/java/org/apache/...
Date Fri, 02 Jun 2006 19:48:03 GMT
Author: akarasulu
Date: Fri Jun  2 12:48:02 2006
New Revision: 411272

URL: http://svn.apache.org/viewvc?rev=411272&view=rev
Log:
reapplying 409468: going to copy this release to the 0.9.5 branch to correct accidental commit

Added:
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
      - copied unchanged from r409468, directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/Entry.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
      - copied unchanged from r409468, directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifControl.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
      - copied unchanged from r409468, directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifReader.java
    directory/releases/shared/0.9.5.1/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
      - copied unchanged from r409468, directory/releases/shared/0.9.5.1/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifReaderTest.java
Removed:
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifIterator.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifIteratorMonitor.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifIteratorMonitorAdapter.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifParser.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifParserImpl.java
    directory/releases/shared/0.9.5.1/ldap/src/test/java/org/apache/directory/shared/ldap/ldif/LdifParserImplTest.java
Modified:
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
    directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java

Modified: directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
URL: http://svn.apache.org/viewvc/directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java?rev=411272&r1=411271&r2=411272&view=diff
==============================================================================
--- directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
(original)
+++ directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
Fri Jun  2 12:48:02 2006
@@ -62,6 +62,7 @@
     public void decode( Object encoded ) throws DecoderException
     {
         ByteBuffer buf;
+        int position = 0;
 
         if ( encoded instanceof ByteBuffer )
         {
@@ -77,42 +78,47 @@
                 + encoded.getClass() );
         }
 
-        if ( log.isDebugEnabled() )
+        while ( buf.hasRemaining() )
         {
-            log.debug( "Decoding the PDU : " );
 
-            if ( buf.hasArray() )
-            {
-                log.debug( StringTools.dumpBytes( buf.array() ) );
-            }
-            else
-            {
-                byte[] array = new byte[buf.capacity()];
-                int i = 0;
+            ldapDecoder.decode( buf, ldapMessageContainer );
 
-                while ( buf.hasRemaining() )
-                {
-                    array[i++] = buf.get();
-                }
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "Decoding the PDU : " );
 
+                int size = buf.position();
                 buf.flip();
+                
+            	byte[] array = new byte[ size - position ];
+            	
+            	for ( int i = position; i < size; i++ )
+            	{
+            		array[ i ] = buf.get();
+            	}
+
+                position = size;
+                
                 log.debug( StringTools.dumpBytes( array ) );
             }
-        }
-
-        while ( buf.hasRemaining() )
-        {
-            ldapDecoder.decode( buf, ldapMessageContainer );
-
+            
             if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
             {
                 if ( log.isDebugEnabled() )
                 {
                     log.debug( "Decoded LdapMessage : " + ldapMessageContainer.getLdapMessage()
);
+                    buf.mark();
                 }
 
                 decoderCallback.decodeOccurred( null, ldapMessageContainer.getLdapMessage()
);
                 ldapMessageContainer.clean();
+            }
+            else
+            {
+            	if ( log.isDebugEnabled() )
+            	{
+            		
+            	}
             }
         }
     }

Modified: directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java?rev=411272&r1=411271&r2=411272&view=diff
==============================================================================
--- directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
(original)
+++ directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/add/AddRequest.java
Fri Jun  2 12:48:02 2006
@@ -144,6 +144,18 @@
         attributes.put( currentAttribute );
     }
 
+    /**
+     * Create a new attributeValue
+     * 
+     * @param type
+     *            The attribute's name (called 'type' in the grammar)
+     */
+    public void addAttributeType( String type )
+    {
+        currentAttribute = new BasicAttribute( type.toLowerCase() );
+        attributes.put( currentAttribute );
+    }
+
 
     /**
      * Add a new value to the current attribute

Modified: directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java?rev=411272&r1=411271&r2=411272&view=diff
==============================================================================
--- directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
(original)
+++ directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyRequest.java
Fri Jun  2 12:48:02 2006
@@ -165,7 +165,18 @@
      */
     public void addAttributeTypeAndValues( LdapString type )
     {
-        currentAttribute = new BasicAttribute( StringTools.lowerCase( type.getString() )
);
+        addAttributeTypeAndValues( type.getString() );
+    }
+
+    /**
+     * Add a new attributeTypeAndValue
+     * 
+     * @param type
+     *            The attribute's name
+     */
+    public void addAttributeTypeAndValues( String type )
+    {
+        currentAttribute = new BasicAttribute( StringTools.lowerCase( type ) );
 
         int operation = 0;
 

Modified: directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java
URL: http://svn.apache.org/viewvc/directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java?rev=411272&r1=411271&r2=411272&view=diff
==============================================================================
--- directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java
(original)
+++ directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/ldif/LdifComposerImpl.java
Fri Jun  2 12:48:02 2006
@@ -54,77 +54,77 @@
      *            the multi map of single and multivalued attributes.
      * @return the LDIF as a String.
      */
-    public String compose( MultiMap a_attrHash )
+    public String compose( MultiMap attrHash )
     {
-        Object l_val = null;
-        String l_key = null;
-        Iterator l_keys = a_attrHash.keySet().iterator();
-        Iterator l_values = null;
-        Collection l_valueCol = null;
-        StringWriter l_sw = new StringWriter();
-        PrintWriter l_out = new PrintWriter( l_sw );
+        Object val = null;
+        String key = null;
+        Iterator keys = attrHash.keySet().iterator();
+        Iterator values = null;
+        Collection valueCol = null;
+        StringWriter sw = new StringWriter();
+        PrintWriter out = new PrintWriter( sw );
 
-        while ( l_keys.hasNext() )
+        while ( keys.hasNext() )
         {
-            l_key = ( String ) l_keys.next();
-            l_valueCol = ( Collection ) a_attrHash.get( l_key );
-            l_values = l_valueCol.iterator();
+            key = ( String ) keys.next();
+            valueCol = ( Collection ) attrHash.get( key );
+            values = valueCol.iterator();
 
-            if ( l_valueCol.isEmpty() )
+            if ( valueCol.isEmpty() )
             {
                 continue;
             }
-            else if ( l_valueCol.size() == 1 )
+            else if ( valueCol.size() == 1 )
             {
-                l_out.print( l_key );
-                l_out.print( ':' );
-                l_val = l_values.next();
+                out.print( key );
+                out.print( ':' );
+                val = values.next();
 
-                if ( l_val.getClass().isArray() )
+                if ( val.getClass().isArray() )
                 {
-                    l_out.print( ": " );
-                    l_out.println( base64encode( ( byte[] ) l_val ) );
+                    out.print( ": " );
+                    out.println( base64encode( ( byte[] ) val ) );
                 }
                 else
                 {
-                    l_out.print( ' ' );
-                    l_out.println( l_val );
+                    out.print( ' ' );
+                    out.println( val );
                 }
                 continue;
             }
 
-            while ( l_values.hasNext() )
+            while ( values.hasNext() )
             {
-                l_out.print( l_key );
-                l_out.print( ':' );
-                l_val = l_values.next();
+                out.print( key );
+                out.print( ':' );
+                val = values.next();
 
-                if ( l_val.getClass().isArray() )
+                if ( val.getClass().isArray() )
                 {
-                    l_out.print( ": " );
-                    l_out.println( base64encode( ( byte[] ) l_val ) );
+                    out.print( ": " );
+                    out.println( base64encode( ( byte[] ) val ) );
                 }
                 else
                 {
-                    l_out.print( ' ' );
-                    l_out.println( l_val );
+                    out.print( ' ' );
+                    out.println( val );
                 }
             }
         }
 
-        return l_sw.getBuffer().toString();
+        return sw.getBuffer().toString();
     }
 
 
     /**
      * Encodes an binary data into a base64 String.
      * 
-     * @param a_byteArray
+     * @param byteArray
      *            the value of a binary attribute.
      * @return the encoded binary data as a char array.
      */
-    public char[] base64encode( byte[] a_byteArray )
+    public char[] base64encode( byte[] byteArray )
     {
-        return Base64.encode( a_byteArray );
+        return Base64.encode( byteArray );
     }
 }

Modified: directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
URL: http://svn.apache.org/viewvc/directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java?rev=411272&r1=411271&r2=411272&view=diff
==============================================================================
--- directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
(original)
+++ directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/PropertiesUtils.java
Fri Jun  2 12:48:02 2006
@@ -23,12 +23,14 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.FileInputStream;
+import java.io.StringReader;
 
 import javax.naming.directory.Attributes;
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.NotImplementedException;
-import org.apache.directory.shared.ldap.ldif.LdifParserImpl;
+import org.apache.directory.shared.ldap.ldif.Entry;
+import org.apache.directory.shared.ldap.ldif.LdifReader;
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 
 
@@ -689,13 +691,16 @@
             return values;
         }
 
-        if ( values == null )
+        String ldif = props.getProperty( key ).trim().replace( '*', '\n' );
+        
+        LdifReader ldifReader = new LdifReader( new StringReader( ldif ) );
+        
+        Entry entry = (Entry)ldifReader.next();
+        
+        if ( entry != null )
         {
-            values = new LockableAttributesImpl();
+        	values = entry.getAttributes();
         }
-
-        String ldif = props.getProperty( key ).trim().replace( '*', '\n' );
-        ( new LdifParserImpl() ).parse( values, ldif );
         return values;
     }
 }

Modified: directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
URL: http://svn.apache.org/viewvc/directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java?rev=411272&r1=411271&r2=411272&view=diff
==============================================================================
--- directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
(original)
+++ directory/releases/shared/0.9.5.1/ldap/src/main/java/org/apache/directory/shared/ldap/util/StringTools.java
Fri Jun  2 12:48:02 2006
@@ -17,12 +17,15 @@
 package org.apache.directory.shared.ldap.util;
 
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.io.FileFilter;
+import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
@@ -38,6 +41,11 @@
  */
 public class StringTools
 {
+    /** The default charset, because it's not provided by JDK 1.5 */
+    private static final String DEFAULT_CHARSET_JDK_1_4 = new OutputStreamWriter( new ByteArrayOutputStream()
).getEncoding();
+    private static final String DEFAULT_CHARSET_JDK_1_5 = Charset.defaultCharset().name();
+    private static final String JAVA_VERSION = System.getProperty( "java.version" );
+    
     /**
      * Trims several consecutive characters into one.
      * 
@@ -2261,5 +2269,20 @@
         }
 
         return sb.toString();
+    }
+
+    /**
+     * @return The default charset
+     */
+    public static String getDefaultCharsetName()
+    {
+        if ( JAVA_VERSION.startsWith( "1.4" ) )
+        {
+            return DEFAULT_CHARSET_JDK_1_4;
+        }
+        else
+        {
+            return DEFAULT_CHARSET_JDK_1_5;
+        }
     }
 }



Mime
View raw message