directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1063083 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/ apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/ apacheds/trunk/ldap-client-test/src/test/java/org/apac...
Date Tue, 25 Jan 2011 00:52:41 GMT
Author: akarasulu
Date: Tue Jan 25 00:52:40 2011
New Revision: 1063083

URL: http://svn.apache.org/viewvc?rev=1063083&view=rev
Log:
Shared refactoring ...

  o added AddRequestDecorator and removed Encodeable interface
  o decoupled AddRequestImpl from codec code, and moved to model
  o modified LdapEncoder to handle decorators


Added:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/AddRequestDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/MessageDecorator.java
  (contents, props changed)
      - copied, changed from r1063063, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/EncodeableDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
  (contents, props changed)
      - copied, changed from r1063063, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java
  (contents, props changed)
      - copied, changed from r1063063, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java
Removed:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AbstractMessageDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/Encodeable.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/EncodeableDecorator.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecorator.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java
Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
    directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java
    directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
    directory/shared/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapEncoder.java
    directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
Tue Jan 25 00:52:40 2011
@@ -47,7 +47,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.filter.SearchScope;
 import org.apache.directory.shared.ldap.model.message.AbandonRequest;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.model.message.*;

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
Tue Jan 25 00:52:40 2011
@@ -53,7 +53,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.*;
 import org.apache.directory.shared.ldap.model.message.ModifyRequest;
 import org.apache.directory.shared.ldap.message.ModifyRequestImpl;

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
(original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAddRequestTest.java
Tue Jan 25 00:52:40 2011
@@ -44,7 +44,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.model.message.BindResponse;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;

Modified: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java
(original)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java
Tue Jan 25 00:52:40 2011
@@ -23,11 +23,11 @@ package org.apache.directory.shared.dsml
 import org.apache.directory.shared.dsmlv2.ParserUtils;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Value;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.dom4j.Element;
 import org.dom4j.Namespace;

Modified: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
(original)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
Tue Jan 25 00:52:40 2011
@@ -59,7 +59,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.AbandonRequest;
 import org.apache.directory.shared.ldap.message.AbandonRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.*;
 import org.apache.directory.shared.ldap.model.message.BindRequest;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;

Modified: directory/shared/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/shared/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Tue Jan 25 00:52:40 2011
@@ -79,7 +79,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.AbandonRequest;
 import org.apache.directory.shared.ldap.message.AbandonRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.model.message.*;
 import org.apache.directory.shared.ldap.model.message.BindRequest;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Tue Jan 25 00:52:40 2011
@@ -71,7 +71,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.AbandonRequest;
 import org.apache.directory.shared.ldap.message.AbandonRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.model.message.*;

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapEncoder.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapEncoder.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapEncoder.java
Tue Jan 25 00:52:40 2011
@@ -36,14 +36,13 @@ import org.apache.directory.shared.i18n.
 import org.apache.directory.shared.ldap.codec.LdapConstants;
 import org.apache.directory.shared.ldap.codec.MessageEncoderException;
 import org.apache.directory.shared.ldap.codec.controls.CodecControl;
+import org.apache.directory.shared.ldap.message.decorators.AddRequestDecorator;
+import org.apache.directory.shared.ldap.message.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.model.entry.BinaryValue;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.Modification;
-import org.apache.directory.shared.ldap.model.message.Control;
-import org.apache.directory.shared.ldap.model.message.LdapResult;
-import org.apache.directory.shared.ldap.model.message.Message;
-import org.apache.directory.shared.ldap.model.message.Referral;
+import org.apache.directory.shared.ldap.model.message.*;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.util.Strings;
 
@@ -81,8 +80,8 @@ public class LdapEncoder
      */
     public ByteBuffer encodeMessage( Message message ) throws EncoderException
     {
-        Encodeable encodeable = new EncodeableDecorator( message );
-        int length = computeMessageLength( encodeable );
+        MessageDecorator decorator = MessageDecorator.getDecorator( message );
+        int length = computeMessageLength( decorator );
         ByteBuffer buffer = ByteBuffer.allocate( length );
 
         try
@@ -93,7 +92,7 @@ public class LdapEncoder
                 buffer.put( UniversalTag.SEQUENCE.getValue() );
 
                 // The length has been calculated by the computeLength method
-                buffer.put( TLV.getBytes( encodeable.getMessageLength() ) );
+                buffer.put( TLV.getBytes(decorator.getMessageLength()) );
             }
             catch ( BufferOverflowException boe )
             {
@@ -104,7 +103,7 @@ public class LdapEncoder
             Value.encode( buffer, message.getMessageId() );
 
             // Add the protocolOp part
-            encodeProtocolOp( buffer, message );
+            encodeProtocolOp( buffer, decorator );
 
             // Do the same thing for Controls, if any.
             Map<String, Control> controls = message.getControls();
@@ -113,7 +112,7 @@ public class LdapEncoder
             {
                 // Encode the controls
                 buffer.put( ( byte ) LdapConstants.CONTROLS_TAG );
-                buffer.put( TLV.getBytes( encodeable.getControlsLength() ) );
+                buffer.put( TLV.getBytes(decorator.getControlsLength()) );
 
                 // Encode each control
                 for ( Control control : controls.values() )
@@ -147,20 +146,20 @@ public class LdapEncoder
      * L1 = length(ProtocolOp) 
      * LdapMessage length = Length(0x30) + Length(L1) + MessageId length + L1
      *
-     * @param encodeable the decorated Message who's length is to be encoded
+     * @param decorator the decorated Message who's length is to be encoded
      */
-    private int computeMessageLength( Encodeable encodeable )
+    private int computeMessageLength( MessageDecorator decorator )
     {
         // The length of the MessageId. It's the sum of
         // - the tag (0x02), 1 byte
         // - the length of the Id length, 1 byte
         // - the Id length, 1 to 4 bytes
-        int ldapMessageLength = 1 + 1 + Value.getNbBytes( encodeable.getMessage().getMessageId()
);
+        int ldapMessageLength = 1 + 1 + Value.getNbBytes( decorator.getMessage().getMessageId());
 
         // Get the protocolOp length
-        ldapMessageLength += computeProtocolOpLength( encodeable.getMessage() );
+        ldapMessageLength += computeProtocolOpLength( decorator );
 
-        Map<String, Control> controls = encodeable.getMessage().getControls();
+        Map<String, Control> controls = decorator.getMessage().getControls();
 
         // Do the same thing for Controls, if any.
         if ( controls.size() > 0 )
@@ -194,14 +193,14 @@ public class LdapEncoder
 
             // Computes the controls length
             // 1 + Length.getNbBytes( controlsSequenceLength ) + controlsSequenceLength;
-            encodeable.setControlsLength( controlsSequenceLength );
+            decorator.setControlsLength( controlsSequenceLength );
 
             // Now, add the tag and the length of the controls length
             ldapMessageLength += 1 + TLV.getNbBytes( controlsSequenceLength ) + controlsSequenceLength;
         }
 
         // Store the messageLength
-        encodeable.setMessageLength( ldapMessageLength );
+        decorator.setMessageLength( ldapMessageLength );
 
         // finally, calculate the global message size :
         // length(Tag) + Length(length) + length
@@ -399,8 +398,9 @@ public class LdapEncoder
      *                    +--> ...
      *                    +--> 0x04 L7-m-n value
      */
-    private int computeAddRequestLength( AddRequestImpl addRequest )
+    private int computeAddRequestLength( AddRequestDecorator decorator )
     {
+        AddRequest addRequest = decorator.getAddRequest();
         Entry entry = addRequest.getEntry();
 
         if ( entry == null )
@@ -450,13 +450,13 @@ public class LdapEncoder
                 valuesLength.add( localValuesLength );
             }
 
-            addRequest.setAttributesLength( attributesLength );
-            addRequest.setValuesLength( valuesLength );
-            addRequest.setEntryLength( entryLength );
+            decorator.setAttributesLength( attributesLength );
+            decorator.setValuesLength( valuesLength );
+            decorator.setEntryLength( entryLength );
         }
 
         addRequestLength += 1 + TLV.getNbBytes( entryLength ) + entryLength;
-        addRequest.setAddRequestLength( addRequestLength );
+        decorator.setAddRequestLength( addRequestLength );
 
         // Return the result.
         return 1 + TLV.getNbBytes( addRequestLength ) + addRequestLength;
@@ -1385,20 +1385,22 @@ public class LdapEncoder
      * 
      * @param buffer The buffer where to put the PDU
      */
-    private void encodeAddRequest( ByteBuffer buffer, AddRequestImpl addRequest ) throws
EncoderException
+    private void encodeAddRequest( ByteBuffer buffer, AddRequestDecorator decorator ) throws
EncoderException
     {
+        AddRequest addRequest = decorator.getAddRequest();
+
         try
         {
             // The AddRequest Tag
             buffer.put( LdapConstants.ADD_REQUEST_TAG );
-            buffer.put( TLV.getBytes( addRequest.getAddRequestLength() ) );
+            buffer.put( TLV.getBytes( decorator.getAddRequestLength() ) );
 
             // The entry
             Value.encode( buffer, Dn.getBytes(addRequest.getEntryDn()) );
 
             // The attributes sequence
             buffer.put( UniversalTag.SEQUENCE.getValue() );
-            buffer.put( TLV.getBytes( addRequest.getEntryLength() ) );
+            buffer.put( TLV.getBytes( decorator.getEntryLength() ) );
 
             // The partial attribute list
             Entry entry = addRequest.getEntry();
@@ -1412,7 +1414,7 @@ public class LdapEncoder
                 {
                     // The attributes list sequence
                     buffer.put( UniversalTag.SEQUENCE.getValue() );
-                    int localAttributeLength = addRequest.getAttributesLength().get( attributeNumber
);
+                    int localAttributeLength = decorator.getAttributesLength().get( attributeNumber
);
                     buffer.put( TLV.getBytes( localAttributeLength ) );
 
                     // The attribute type
@@ -1420,7 +1422,7 @@ public class LdapEncoder
 
                     // The values
                     buffer.put( UniversalTag.SET.getValue() );
-                    int localValuesLength = addRequest.getValuesLength().get( attributeNumber
);
+                    int localValuesLength = decorator.getValuesLength().get( attributeNumber
);
                     buffer.put( TLV.getBytes( localValuesLength ) );
 
                     if ( attribute.size() != 0 )
@@ -2351,15 +2353,17 @@ public class LdapEncoder
     /**
      * Compute the protocolOp length 
      */
-    private int computeProtocolOpLength( Message message )
+    private int computeProtocolOpLength( MessageDecorator decorator )
     {
+        Message message = decorator.getMessage();
+
         switch ( message.getType() )
         {
             case ABANDON_REQUEST:
                 return computeAbandonRequestLength( ( AbandonRequestImpl ) message );
 
             case ADD_REQUEST:
-                return computeAddRequestLength( ( AddRequestImpl ) message );
+                return computeAddRequestLength( ( AddRequestDecorator ) decorator );
 
             case ADD_RESPONSE:
                 return computeAddResponseLength( ( AddResponseImpl ) message );
@@ -2424,8 +2428,10 @@ public class LdapEncoder
     }
 
 
-    private void encodeProtocolOp( ByteBuffer bb, Message message ) throws EncoderException
+    private void encodeProtocolOp( ByteBuffer bb, MessageDecorator decorator ) throws EncoderException
     {
+        Message message = decorator.getMessage();
+
         switch ( message.getType() )
         {
             case ABANDON_REQUEST:
@@ -2433,7 +2439,7 @@ public class LdapEncoder
                 break;
 
             case ADD_REQUEST:
-                encodeAddRequest( bb, ( AddRequestImpl ) message );
+                encodeAddRequest( bb, ( AddRequestDecorator ) decorator );
                 break;
 
             case ADD_RESPONSE:

Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/AddRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/AddRequestDecorator.java?rev=1063083&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/AddRequestDecorator.java
(added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/AddRequestDecorator.java
Tue Jan 25 00:52:40 2011
@@ -0,0 +1,142 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  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. 
+ *  
+ */
+package org.apache.directory.shared.ldap.message.decorators;
+
+
+import java.util.List;
+import org.apache.directory.shared.ldap.model.message.AddRequest;
+
+
+/**
+ * Example to show decorator application. The decorator interface is CodecControl which
+ * adds the additional functionality. This class would be the concrete decorator for the
+ * CodecControl. The decorated component is Control, and an example of a concrete
+ * decorated component would be LdifControl.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class AddRequestDecorator extends MessageDecorator
+{
+    // ~ Instance fields
+    // ----------------------------------------------------------------------------
+
+    /** The add request length */
+    private int addRequestLength;
+
+    /** The Entry length */
+    private int entryLength;
+
+    /** The list of all attributes length */
+    private List<Integer> attributesLength;
+
+    /** The list of all vals length */
+    private List<Integer> valuesLength;
+
+
+    /**
+     * Makes a AddRequest encodable.
+     */
+    public AddRequestDecorator( AddRequest decoratedMessage )
+    {
+        super( decoratedMessage );
+    }
+
+
+    public AddRequest getAddRequest()
+    {
+        return ( AddRequest ) getMessage();
+    }
+
+
+    /**
+     * Stores the encoded length for the AddRequest
+     * @param addRequestLength The encoded length
+     */
+    public void setAddRequestLength( int addRequestLength )
+    {
+        this.addRequestLength = addRequestLength;
+    }
+
+
+    /**
+     * @return The encoded AddRequest's length
+     */
+    public int getAddRequestLength()
+    {
+        return addRequestLength;
+    }
+
+
+    /**
+     * Stores the encoded length for the Entry
+     * @param entryLength The encoded length
+     */
+    public void setEntryLength( int entryLength )
+    {
+        this.entryLength = entryLength;
+    }
+
+
+    /**
+     * @return The encoded Entry's length
+     */
+    public int getEntryLength()
+    {
+        return entryLength;
+    }
+
+
+    /**
+     * Stores the encoded length for the attributes
+     * @param attributesLength The encoded length
+     */
+    public void setAttributesLength( List<Integer> attributesLength )
+    {
+        this.attributesLength = attributesLength;
+    }
+
+
+    /**
+     * @return The encoded values length
+     */
+    public List<Integer> getAttributesLength()
+    {
+        return attributesLength;
+    }
+
+
+    /**
+     * Stores the encoded length for the values
+     * @param valuesLength The encoded length
+     */
+    public void setValuesLength( List<Integer> valuesLength )
+    {
+        this.valuesLength = valuesLength;
+    }
+
+
+    /**
+     * @return The encoded values length
+     */
+    public List<Integer> getValuesLength()
+    {
+        return valuesLength;
+    }
+}

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/MessageDecorator.java
(from r1063063, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/EncodeableDecorator.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/MessageDecorator.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/MessageDecorator.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/EncodeableDecorator.java&r1=1063063&r2=1063083&rev=1063083&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/EncodeableDecorator.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/MessageDecorator.java
Tue Jan 25 00:52:40 2011
@@ -17,21 +17,21 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.message;
+package org.apache.directory.shared.ldap.message.decorators;
 
 
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.ldap.model.message.AddRequest;
 import org.apache.directory.shared.ldap.model.message.Message;
 
 
 /**
- * Example to show decorator application. The decorator interface is CodecControl which
- * adds the additional functionality. This class would be the concrete decorator for the
- * CodecControl. The decorated component is Control, and an example of a concrete
- * decorated component would be LdifControl.
- * 
+ * Doc me man!
+ *
+ * @TODO make this class abstract, after finishing switch and all types and make default
blow an EncoderException
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class EncodeableDecorator implements Encodeable
+public class MessageDecorator
 {
     // ~ Instance fields
     // ----------------------------------------------------------------------------
@@ -46,10 +46,24 @@ public class EncodeableDecorator impleme
     private int controlsLength;
 
 
+    public static MessageDecorator getDecorator( Message decoratedMessage ) throws EncoderException
+    {
+        switch ( decoratedMessage.getType() )
+        {
+            case ADD_REQUEST:
+                return new AddRequestDecorator( ( AddRequest ) decoratedMessage );
+            default:
+                return new MessageDecorator( decoratedMessage );
+        }
+    }
+
+
     /**
      * Makes a Message an Encodeable object.
+     *
+     * @TODO make me protected after making this class abstract
      */
-    public EncodeableDecorator(Message decoratedMessage)
+    public MessageDecorator( Message decoratedMessage )
     {
         this.decoratedMessage = decoratedMessage;
     }

Propchange: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/decorators/MessageDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
(from r1063063, directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java?p2=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java&p1=directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java&r1=1063063&r2=1063083&rev=1063083&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/message/AddRequestImpl.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
Tue Jan 25 00:52:40 2011
@@ -17,11 +17,11 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.message;
+package org.apache.directory.shared.ldap.model.message;
 
 
-import java.util.List;
-
+import org.apache.directory.shared.ldap.message.AbstractAbandonableRequest;
+import org.apache.directory.shared.ldap.message.AddResponseImpl;
 import org.apache.directory.shared.ldap.model.entry.*;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
@@ -49,18 +49,6 @@ public class AddRequestImpl extends Abst
     /** The current attribute being decoded */
     private EntryAttribute currentAttribute;
 
-    /** The add request length */
-    private int addRequestLength;
-
-    /** The Entry length */
-    private int entryLength;
-
-    /** The list of all attributes length */
-    private List<Integer> attributesLength;
-
-    /** The list of all vals length */
-    private List<Integer> valuesLength;
-
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -231,82 +219,6 @@ public class AddRequestImpl extends Abst
 
 
     /**
-     * Stores the encoded length for the AddRequest
-     * @param addRequestLength The encoded length
-     */
-    /* No qualifier*/void setAddRequestLength( int addRequestLength )
-    {
-        this.addRequestLength = addRequestLength;
-    }
-
-
-    /**
-     * @return The encoded AddRequest's length
-     */
-    /* No qualifier */int getAddRequestLength()
-    {
-        return addRequestLength;
-    }
-
-
-    /**
-     * Stores the encoded length for the Entry
-     * @param entryLength The encoded length
-     */
-    /* No qualifier*/void setEntryLength( int entryLength )
-    {
-        this.entryLength = entryLength;
-    }
-
-
-    /**
-     * @return The encoded Entry's length
-     */
-    /* No qualifier */int getEntryLength()
-    {
-        return entryLength;
-    }
-
-
-    /**
-     * Stores the encoded length for the attributes
-     * @param atributesLength The encoded length
-     */
-    /* No qualifier*/void setAttributesLength( List<Integer> attributesLength )
-    {
-        this.attributesLength = attributesLength;
-    }
-
-
-    /**
-     * @return The encoded values length
-     */
-    /* No qualifier */List<Integer> getAttributesLength()
-    {
-        return attributesLength;
-    }
-
-
-    /**
-     * Stores the encoded length for the values
-     * @param valuesLength The encoded length
-     */
-    /* No qualifier*/void setValuesLength( List<Integer> valuesLength )
-    {
-        this.valuesLength = valuesLength;
-    }
-
-
-    /**
-     * @return The encoded values length
-     */
-    /* No qualifier */List<Integer> getValuesLength()
-    {
-        return valuesLength;
-    }
-
-
-    /**
      * Checks to see if an object is equivalent to this AddRequest. First
      * there's a quick test to see if the obj is the same object as this one -
      * if so true is returned. Next if the super method fails false is returned.

Propchange: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java
(from r1063063, directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java)
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java?p2=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java&p1=directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java&r1=1063063&r2=1063083&rev=1063083&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/message/AddRequestImplTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java
Tue Jan 25 00:52:40 2011
@@ -17,7 +17,7 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.message;
+package org.apache.directory.shared.ldap.model.message;
 
 
 import static org.junit.Assert.assertFalse;
@@ -34,12 +34,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.exception.MessageException;
-import org.apache.directory.shared.ldap.model.message.AbandonListener;
-import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.model.entry.Value;
-import org.apache.directory.shared.ldap.model.message.Control;
-import org.apache.directory.shared.ldap.model.message.ResultResponse;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.junit.Test;
 import org.junit.runner.RunWith;

Propchange: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java?rev=1063083&r1=1063082&r2=1063083&view=diff
==============================================================================
--- directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
(original)
+++ directory/studio/trunk/plugins/connection.core/src/main/java/org/apache/directory/studio/connection/core/io/api/DirectoryApiConnectionWrapper.java
Tue Jan 25 00:52:40 2011
@@ -47,7 +47,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.message.AddRequest;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
+import org.apache.directory.shared.ldap.model.message.AddRequestImpl;
 import org.apache.directory.shared.ldap.model.message.AddResponse;
 import org.apache.directory.shared.ldap.model.message.*;
 import org.apache.directory.shared.ldap.model.message.DeleteRequest;



Mime
View raw message