directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1332310 - in /directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators: SearchRequestDecorator.java SearchResultEntryDecorator.java
Date Mon, 30 Apr 2012 17:39:03 GMT
Author: elecharny
Date: Mon Apr 30 17:39:02 2012
New Revision: 1332310

URL: http://svn.apache.org/viewvc?rev=1332310&view=rev
Log:
Fif for DIRAPI-84, and a small improvement for Entries being encoded

Modified:
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java?rev=1332310&r1=1332309&r2=1332310&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchRequestDecorator.java
Mon Apr 30 17:39:02 2012
@@ -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.codec.decorators;
 
@@ -99,6 +99,9 @@ public class SearchRequestDecorator exte
 
     /** The SearchRequest TLV id */
     private int tlvId;
+    
+    /** The bytes containing the Dn */
+    private byte[] dnBytes;
 
 
     /**
@@ -333,7 +336,7 @@ public class SearchRequestDecorator exte
                 {
                     // The parent is a filter ; it will become the new currentFilter
                     // and we will loop again.
-                    currentFilter = ( Filter ) filterParent;
+                    currentFilter = filterParent;
                     localFilter = currentFilter;
                     localParent = localParent.getParent();
                 }
@@ -926,12 +929,12 @@ public class SearchRequestDecorator exte
      *  +--> filter.computeLength()
      *  +--> 0x30 L3 (Attribute description list)
      *        |
-     *        +--> 0x04 L4-1 Attribute description 
-     *        +--> 0x04 L4-2 Attribute description 
-     *        +--> ... 
-     *        +--> 0x04 L4-i Attribute description 
-     *        +--> ... 
-     *        +--> 0x04 L4-n Attribute description 
+     *        +--> 0x04 L4-1 Attribute description
+     *        +--> 0x04 L4-2 Attribute description
+     *        +--> ...
+     *        +--> 0x04 L4-i Attribute description
+     *        +--> ...
+     *        +--> 0x04 L4-n Attribute description
      *        </pre>
      */
     public int computeLength()
@@ -939,7 +942,8 @@ public class SearchRequestDecorator exte
         int searchRequestLength = 0;
 
         // The baseObject
-        searchRequestLength += 1 + TLV.getNbBytes( Dn.getNbBytes( getBase() ) ) + Dn.getNbBytes(
getBase() );
+        dnBytes = Strings.getBytesUtf8( getBase().getName() );
+        searchRequestLength += 1 + TLV.getNbBytes( dnBytes.length ) + dnBytes.length;
 
         // The scope
         searchRequestLength += 1 + 1 + 1;
@@ -1000,7 +1004,7 @@ public class SearchRequestDecorator exte
      *   filter.encode()
      *   0x30 LL attributeDescriptionList
      *     0x04 LL attributeDescription
-     *     ... 
+     *     ...
      *     0x04 LL attributeDescription
      * </pre>
      * @param buffer The buffer where to put the PDU
@@ -1015,7 +1019,7 @@ public class SearchRequestDecorator exte
             buffer.put( TLV.getBytes( getSearchRequestLength() ) );
 
             // The baseObject
-            org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, Dn.getBytes( getBase()
) );
+            org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, dnBytes );
 
             // The scope
             org.apache.directory.shared.asn1.ber.tlv.Value.encodeEnumerated( buffer, getScope().getScope()
);

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java?rev=1332310&r1=1332309&r2=1332310&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java
Mon Apr 30 17:39:02 2012
@@ -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.codec.decorators;
 
@@ -29,7 +29,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
-import org.apache.directory.shared.asn1.util.Asn1StringUtils;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.api.LdapApiService;
 import org.apache.directory.shared.ldap.codec.api.LdapConstants;
@@ -62,6 +61,9 @@ public class SearchResultEntryDecorator 
     /** The list of all attributes length */
     private List<Integer> attributeLength;
 
+    /** The list of all attributes Id bytes */
+    private List<byte[]> attributeIds;
+
     /** The list of all vals length */
     private List<Integer> valsLength;
 
@@ -316,6 +318,7 @@ public class SearchResultEntryDecorator 
         if ( ( entry != null ) && ( entry.size() != 0 ) )
         {
             List<Integer> attributeLength = new LinkedList<Integer>();
+            attributeIds = new LinkedList<byte[]>();
             List<Integer> valsLength = new LinkedList<Integer>();
 
             // Store those lists in the object
@@ -329,7 +332,9 @@ public class SearchResultEntryDecorator 
                 int localValuesLength = 0;
 
                 // Get the type length
-                int idLength = attribute.getUpId().getBytes().length;
+                byte[] atrributeIdBytes = attribute.getUpId().getBytes();
+                attributeIds.add( atrributeIdBytes );
+                int idLength = atrributeIdBytes.length;
                 localAttributeLength = 1 + TLV.getNbBytes( idLength ) + idLength;
 
                 if ( attribute.size() != 0 )
@@ -377,7 +382,7 @@ public class SearchResultEntryDecorator 
 
         searchResultEntryLength += 1 + TLV.getNbBytes( attributesLength ) + attributesLength;
 
-        // Store the length of the response 
+        // Store the length of the response
         setSearchResultEntryLength( searchResultEntryLength );
 
         // Return the result.
@@ -397,15 +402,15 @@ public class SearchResultEntryDecorator 
      *       0x04 LL type
      *       0x31 LL vals
      *         0x04 LL attributeValue
-     *         ... 
+     *         ...
      *         0x04 LL attributeValue
-     *     ... 
+     *     ...
      *     0x30 LL partialAttributeList
      *       0x04 LL type
      *       0x31 LL vals
      *         0x04 LL attributeValue
-     *         ... 
-     *         0x04 LL attributeValue 
+     *         ...
+     *         0x04 LL attributeValue
      * </pre>
      * @param buffer The buffer where to put the PDU
      * @param searchResultEntryDecorator the SearchResultEntry decorator
@@ -442,7 +447,7 @@ public class SearchResultEntryDecorator 
                     buffer.put( TLV.getBytes( localAttributeLength ) );
 
                     // The attribute type
-                    Value.encode( buffer, Asn1StringUtils.asciiStringToByte( attribute.getUpId()
) );
+                    Value.encode( buffer, attributeIds.get( attributeNumber ) );
 
                     // The values
                     buffer.put( UniversalTag.SET.getValue() );



Mime
View raw message