directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r986545 - in /directory: apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/
Date Wed, 18 Aug 2010 01:07:15 GMT
Author: elecharny
Date: Wed Aug 18 01:07:14 2010
New Revision: 986545

URL: http://svn.apache.org/viewvc?rev=986545&view=rev
Log:
o More codec classes removal
o Commented the code inside ImportCommand, which needs to be rewritten to use the API instead
of plain socket.

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageCodec.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResponseCodec.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapResultCodec.java
Modified:
    directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java

Modified: directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java?rev=986545&r1=986544&r2=986545&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
(original)
+++ directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
Wed Aug 18 01:07:14 2010
@@ -35,42 +35,12 @@ import org.apache.directory.daemon.Avail
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.asn1.ber.Asn1Decoder;
 import org.apache.directory.shared.asn1.ber.IAsn1Container;
-import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
-import org.apache.directory.shared.ldap.codec.LdapMessageCodec;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
-import org.apache.directory.shared.ldap.codec.LdapResultCodec;
-import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Modification;
-import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.ldif.ChangeType;
-import org.apache.directory.shared.ldap.ldif.LdifEntry;
-import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.apache.directory.shared.ldap.message.AddRequestImpl;
-import org.apache.directory.shared.ldap.message.BindRequestImpl;
-import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
 import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
-import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
-import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
-import org.apache.directory.shared.ldap.message.internal.BindResponse;
-import org.apache.directory.shared.ldap.message.internal.ExtendedResponse;
-import org.apache.directory.shared.ldap.message.internal.AddRequest;
-import org.apache.directory.shared.ldap.message.internal.BindRequest;
-import org.apache.directory.shared.ldap.message.internal.DeleteRequest;
-import org.apache.directory.shared.ldap.message.internal.Message;
-import org.apache.directory.shared.ldap.message.internal.ModifyDnRequest;
-import org.apache.directory.shared.ldap.message.internal.ModifyRequest;
 import org.apache.directory.shared.ldap.message.internal.UnbindRequest;
-import org.apache.directory.shared.ldap.name.DN;
-import org.apache.directory.shared.ldap.name.RDN;
-import org.apache.directory.shared.ldap.util.StringTools;
 
 
 /**
@@ -150,9 +120,9 @@ public class ImportCommand extends ToolC
     }
 
 
+    /*
     private LdapMessageCodec readResponse( ByteBuffer bb ) throws IOException, DecoderException
     {
-
         LdapMessageCodec messageResp = null;
 
         while ( true )
@@ -206,7 +176,6 @@ public class ImportCommand extends ToolC
         }
 
         return messageResp;
-
     }
 
 
@@ -214,11 +183,9 @@ public class ImportCommand extends ToolC
      * Send the entry to the encoder, then wait for a
      * reponse from the LDAP server on the results of the operation.
      * 
-     * @param ldifEntry
-     *            The entry to add
-     * @param msgId
-     *            message id number
-     */
+     * @param ldifEntry The entry to add
+     * @param msgId message id number
+     *
     private int addEntry( LdifEntry ldifEntry, int messageId ) throws IOException, DecoderException,
LdapException,
         EncoderException
     {
@@ -288,7 +255,7 @@ public class ImportCommand extends ToolC
      *            The entry to delete
      * @param msgId
      *            message id number
-     */
+     *
     private int deleteEntry( LdifEntry entry, int messageId ) throws IOException, DecoderException,
         LdapInvalidDnException, EncoderException
     {
@@ -342,7 +309,7 @@ public class ImportCommand extends ToolC
      *            The entry to modify
      * @param msgId
      *            message id number
-     */
+     *
     private int changeModRDNEntry( LdifEntry entry, int messageId ) throws IOException, DecoderException,
         LdapInvalidDnException, EncoderException
     {
@@ -404,7 +371,7 @@ public class ImportCommand extends ToolC
      * 
      * @param entry The entry to modify
      * @param msgId message id number
-     */
+     *
     private int changeModifyEntry( LdifEntry entry, int messageId ) throws IOException, DecoderException,
         LdapInvalidDnException, EncoderException
     {
@@ -466,7 +433,7 @@ public class ImportCommand extends ToolC
      *            The entry to add
      * @param msgId
      *            message id number
-     */
+     *
     private int changeEntry( LdifEntry entry, int messageId ) throws IOException, DecoderException,
LdapException,
         EncoderException
     {
@@ -496,7 +463,7 @@ public class ImportCommand extends ToolC
      * Bind to the ldap server
      * 
      * @param messageId The message Id
-     */
+     *
     private void bind( int messageId ) throws LdapInvalidDnException, EncoderException, DecoderException,
IOException
     {
         BindRequest bindRequest = new BindRequestImpl( messageId );
@@ -574,6 +541,11 @@ public class ImportCommand extends ToolC
      */
     public void execute( CommandLine cmd ) throws Exception
     {
+        return;
+    }
+
+
+    /*
         processOptions( cmd );
 
         if ( isDebugEnabled() )

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java?rev=986545&r1=986544&r2=986545&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapEncoder.java
Wed Aug 18 01:07:14 2010
@@ -20,20 +20,14 @@
 package org.apache.directory.shared.ldap.codec;
 
 
-import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.WritableByteChannel;
 
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.asn1.codec.stateful.EncoderCallback;
-import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.message.internal.Message;
 import org.apache.directory.shared.ldap.message.spi.Provider;
 import org.apache.directory.shared.ldap.message.spi.ProviderEncoder;
 import org.apache.directory.shared.ldap.message.spi.ProviderException;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,10 +39,6 @@ import org.slf4j.LoggerFactory;
  */
 public class LdapEncoder implements ProviderEncoder
 {
-    //TM private static long cumul = 0L;
-    //TM private static long count = 0L;
-    //TM private Object lock = new Object();
-
     /** The logger */
     private static Logger log = LoggerFactory.getLogger( LdapEncoder.class );
 
@@ -58,9 +48,6 @@ public class LdapEncoder implements Prov
     /** The associated Provider */
     final Provider provider;
 
-    /** The callback to call when the encoding is done */
-    private EncoderCallback encodeCallback;
-
 
     /**
      * Creates an instance of a Ldap Encoder implementation.
@@ -83,36 +70,6 @@ public class LdapEncoder implements Prov
      */
     public void encodeBlocking( Object lock, OutputStream out, Object obj ) throws ProviderException
     {
-        try
-        {
-            if ( IS_DEBUG )
-            {
-                log.debug( "Encoding this LdapMessage : " + obj );
-            }
-
-            ByteBuffer encoded = ( ( LdapMessageCodec ) obj ).encode();
-
-            try
-            {
-                ( ( ByteBuffer ) encoded ).flip();
-                WritableByteChannel channel = Channels.newChannel( out );
-                channel.write( ( ByteBuffer ) encoded );
-            }
-            catch ( IOException e )
-            {
-                ProviderException pe = new ProviderException( provider, I18n.err( I18n.ERR_04065,
"", e
-                    .getLocalizedMessage() ) );
-                throw pe;
-            }
-
-        }
-        catch ( EncoderException e )
-        {
-            String msg = I18n.err( I18n.ERR_04065, obj, e.getLocalizedMessage() );
-            log.error( msg );
-            ProviderException pe = new ProviderException( provider, msg );
-            throw pe;
-        }
     }
 
 
@@ -126,66 +83,7 @@ public class LdapEncoder implements Prov
      */
     public ByteBuffer encodeBlocking( Object obj ) throws ProviderException
     {
-        try
-        {
-            if ( IS_DEBUG )
-            {
-                log.debug( "Encoding this LdapMessage : " + obj );
-            }
-
-            ByteBuffer pdu = ( ( LdapMessageCodec ) obj ).encode();
-
-            if ( IS_DEBUG )
-            {
-                log.debug( "Encoded PDU : " + StringTools.dumpBytes( pdu.array() ) );
-            }
-
-            pdu.flip();
-            return pdu;
-        }
-        catch ( EncoderException e )
-        {
-            String msg = I18n.err( I18n.ERR_04065, obj, e.getLocalizedMessage() );
-            log.error( msg );
-            ProviderException pe = new ProviderException( provider, msg );
-            throw pe;
-        }
-    }
-
-
-    /**
-     * Encodes a LdapMessage, and return a byte array containing the resulting
-     * PDU
-     * 
-     * @param obj The LdapMessage to encode
-     * @return The byte[] containing the PDU
-     * @throws ProviderException If anything went wrong
-     */
-    public byte[] encodeToArray( Object obj ) throws ProviderException
-    {
-        try
-        {
-            if ( IS_DEBUG )
-            {
-                log.debug( "Encoding this LdapMessage : " + obj );
-            }
-
-            byte[] pdu = ( ( LdapMessageCodec ) obj ).encode().array();
-
-            if ( IS_DEBUG )
-            {
-                log.debug( "Encoded PDU : " + StringTools.dumpBytes( pdu ) );
-            }
-
-            return pdu;
-        }
-        catch ( EncoderException e )
-        {
-            String msg = I18n.err( I18n.ERR_04065, obj, e.getLocalizedMessage() );
-            log.error( msg );
-            ProviderException pe = new ProviderException( provider, msg );
-            throw pe;
-        }
+        return null;
     }
 
 
@@ -208,30 +106,6 @@ public class LdapEncoder implements Prov
      */
     public void encode( Object request ) throws EncoderException
     {
-        //TM long t0 = System.nanoTime();
-        Message message = ( Message ) request;
-        ByteBuffer encoded = null;
-
-        LdapMessageCodec ldapRequest = ( LdapMessageCodec ) LdapTransformer.transform( (
Message ) request );
-        encoded = ldapRequest.encode();
-
-        encoded.flip();
-
-        encodeCallback.encodeOccurred( null, encoded );
-        //TM long t1 = System.nanoTime();
-
-        //TM synchronized (lock)
-        //TM {
-        //TM     cumul += (t1 - t0);
-        //TM     count++;
-        //TM    
-        //TM
-        //TM     if ( count % 1000L == 0)
-        //TM     {
-        //TM         System.out.println( "Encode cost : " + (cumul/count) );
-        //TM         cumul = 0L;
-        //TM     }
-        //TM }
     }
 
 
@@ -242,6 +116,5 @@ public class LdapEncoder implements Prov
      */
     public void setCallback( EncoderCallback cb )
     {
-        encodeCallback = cb;
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java?rev=986545&r1=986544&r2=986545&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
Wed Aug 18 01:07:14 2010
@@ -20,40 +20,7 @@
 package org.apache.directory.shared.ldap.codec;
 
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.codec.search.AndFilter;
-import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
-import org.apache.directory.shared.ldap.codec.search.ConnectorFilter;
-import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
-import org.apache.directory.shared.ldap.codec.search.Filter;
-import org.apache.directory.shared.ldap.codec.search.NotFilter;
-import org.apache.directory.shared.ldap.codec.search.OrFilter;
-import org.apache.directory.shared.ldap.codec.search.PresentFilter;
-import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
-import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.filter.AndNode;
-import org.apache.directory.shared.ldap.filter.ApproximateNode;
-import org.apache.directory.shared.ldap.filter.BranchNode;
-import org.apache.directory.shared.ldap.filter.EqualityNode;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.ExtensibleNode;
-import org.apache.directory.shared.ldap.filter.GreaterEqNode;
-import org.apache.directory.shared.ldap.filter.LeafNode;
-import org.apache.directory.shared.ldap.filter.LessEqNode;
-import org.apache.directory.shared.ldap.filter.NotNode;
-import org.apache.directory.shared.ldap.filter.OrNode;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
-import org.apache.directory.shared.ldap.filter.SubstringNode;
-import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.Message;
-import org.apache.directory.shared.ldap.schema.SchemaManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -63,302 +30,6 @@ import org.slf4j.LoggerFactory;
  */
 public class LdapTransformer
 {
-    /** The logger */
-    private static Logger LOG = LoggerFactory.getLogger( LdapTransformer.class );
-
-    /** A speedup for logger */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
-    /**
-     * Transform the Filter part of a SearchRequest to an ExprNode
-     * 
-     * @param codecFilter The filter to be transformed
-     * @return An ExprNode
-     */
-    private static ExprNode transformFilter( Filter codecFilter )
-    {
-        if ( codecFilter != null )
-        {
-            // Transform OR, AND or NOT leaves
-            if ( codecFilter instanceof ConnectorFilter )
-            {
-                BranchNode branch = null;
-
-                if ( codecFilter instanceof AndFilter )
-                {
-                    branch = new AndNode();
-                }
-                else if ( codecFilter instanceof OrFilter )
-                {
-                    branch = new OrNode();
-                }
-                else if ( codecFilter instanceof NotFilter )
-                {
-                    branch = new NotNode();
-                }
-
-                List<Filter> filtersSet = ( ( ConnectorFilter ) codecFilter ).getFilterSet();
-
-                // Loop on all AND/OR children
-                if ( filtersSet != null )
-                {
-                    for ( Filter filter : filtersSet )
-                    {
-                        branch.addNode( transformFilter( filter ) );
-                    }
-                }
-
-                return branch;
-            }
-            else
-            {
-                // Transform PRESENT or ATTRIBUTE_VALUE_ASSERTION
-                LeafNode branch = null;
-
-                if ( codecFilter instanceof PresentFilter )
-                {
-                    branch = new PresenceNode( ( ( PresentFilter ) codecFilter ).getAttributeDescription()
);
-                }
-                else if ( codecFilter instanceof AttributeValueAssertionFilter )
-                {
-                    AttributeValueAssertion ava = ( ( AttributeValueAssertionFilter ) codecFilter
).getAssertion();
-
-                    // Transform =, >=, <=, ~= filters
-                    switch ( ( ( AttributeValueAssertionFilter ) codecFilter ).getFilterType()
)
-                    {
-                        case LdapConstants.EQUALITY_MATCH_FILTER:
-                            branch = new EqualityNode( ava.getAttributeDesc(), ava.getAssertionValue()
);
-
-                            break;
-
-                        case LdapConstants.GREATER_OR_EQUAL_FILTER:
-                            branch = new GreaterEqNode( ava.getAttributeDesc(), ava.getAssertionValue()
);
-
-                            break;
-
-                        case LdapConstants.LESS_OR_EQUAL_FILTER:
-                            branch = new LessEqNode( ava.getAttributeDesc(), ava.getAssertionValue()
);
-
-                            break;
-
-                        case LdapConstants.APPROX_MATCH_FILTER:
-                            branch = new ApproximateNode( ava.getAttributeDesc(), ava.getAssertionValue()
);
-
-                            break;
-                    }
-
-                }
-                else if ( codecFilter instanceof SubstringFilter )
-                {
-                    // Transform Substring filters
-                    SubstringFilter filter = ( SubstringFilter ) codecFilter;
-                    String initialString = null;
-                    String finalString = null;
-                    List<String> anyString = null;
-
-                    if ( filter.getInitialSubstrings() != null )
-                    {
-                        initialString = filter.getInitialSubstrings();
-                    }
-
-                    if ( filter.getFinalSubstrings() != null )
-                    {
-                        finalString = filter.getFinalSubstrings();
-                    }
-
-                    if ( filter.getAnySubstrings() != null )
-                    {
-                        anyString = new ArrayList<String>();
-
-                        for ( String any : filter.getAnySubstrings() )
-                        {
-                            anyString.add( any );
-                        }
-                    }
-
-                    branch = new SubstringNode( anyString, filter.getType(), initialString,
finalString );
-                }
-                else if ( codecFilter instanceof ExtensibleMatchFilter )
-                {
-                    // Transform Extensible Match Filter
-                    ExtensibleMatchFilter filter = ( ExtensibleMatchFilter ) codecFilter;
-                    String matchingRule = null;
-
-                    Value<?> value = filter.getMatchValue();
-
-                    if ( filter.getMatchingRule() != null )
-                    {
-                        matchingRule = filter.getMatchingRule();
-                    }
-
-                    branch = new ExtensibleNode( filter.getType(), value, matchingRule, filter.isDnAttributes()
);
-                }
-
-                return branch;
-            }
-        }
-        else
-        {
-            // We have found nothing to transform. Return null then.
-            return null;
-        }
-    }
-
-
-    /**
-     * Transform an ExprNode filter to a CodecFilter
-     * 
-     * @param exprNode The filter to be transformed
-     * @return A Codec filter
-     */
-    public static Filter transformFilter( SchemaManager schemaManager, ExprNode exprNode
)
-    {
-        if ( exprNode != null )
-        {
-            Filter filter = null;
-
-            // Transform OR, AND or NOT leaves
-            if ( exprNode instanceof BranchNode )
-            {
-                if ( exprNode instanceof AndNode )
-                {
-                    filter = new AndFilter();
-                }
-                else if ( exprNode instanceof OrNode )
-                {
-                    filter = new OrFilter();
-                }
-                else if ( exprNode instanceof NotNode )
-                {
-                    filter = new NotFilter();
-                }
-
-                List<ExprNode> children = ( ( BranchNode ) exprNode ).getChildren();
-
-                // Loop on all AND/OR children
-                if ( children != null )
-                {
-                    for ( ExprNode child : children )
-                    {
-                        try
-                        {
-                            ( ( ConnectorFilter ) filter ).addFilter( transformFilter( schemaManager,
child ) );
-                        }
-                        catch ( DecoderException de )
-                        {
-                            LOG.error( I18n.err( I18n.ERR_04112, de.getLocalizedMessage()
) );
-                            return null;
-                        }
-                    }
-                }
-            }
-            else
-            {
-                if ( exprNode instanceof PresenceNode )
-                {
-                    // Transform Presence Node
-                    filter = new PresentFilter();
-                    ( ( PresentFilter ) filter ).setAttributeDescription( ( ( PresenceNode
) exprNode ).getAttribute() );
-                }
-                else if ( exprNode instanceof SimpleNode<?> )
-                {
-                    if ( exprNode instanceof EqualityNode<?> )
-                    {
-                        filter = new AttributeValueAssertionFilter( LdapConstants.EQUALITY_MATCH_FILTER
);
-                        AttributeValueAssertion assertion = new AttributeValueAssertion();
-                        assertion.setAttributeDesc( ( ( EqualityNode<?> ) exprNode
).getAttribute() );
-                        assertion.setAssertionValue( ( ( EqualityNode<?> ) exprNode
).getValue() );
-                        ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion
);
-                    }
-                    else if ( exprNode instanceof GreaterEqNode<?> )
-                    {
-                        filter = new AttributeValueAssertionFilter( LdapConstants.GREATER_OR_EQUAL_FILTER
);
-                        AttributeValueAssertion assertion = new AttributeValueAssertion();
-                        assertion.setAttributeDesc( ( ( GreaterEqNode<?> ) exprNode
).getAttribute() );
-                        assertion.setAssertionValue( ( ( GreaterEqNode<?> ) exprNode
).getValue() );
-                        ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion
);
-                    }
-                    else if ( exprNode instanceof LessEqNode<?> )
-                    {
-                        filter = new AttributeValueAssertionFilter( LdapConstants.LESS_OR_EQUAL_FILTER
);
-                        AttributeValueAssertion assertion = new AttributeValueAssertion();
-                        assertion.setAttributeDesc( ( ( LessEqNode<?> ) exprNode ).getAttribute()
);
-                        assertion.setAssertionValue( ( ( LessEqNode<?> ) exprNode ).getValue()
);
-                        ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion
);
-                    }
-                    else if ( exprNode instanceof ApproximateNode<?> )
-                    {
-                        filter = new AttributeValueAssertionFilter( LdapConstants.APPROX_MATCH_FILTER
);
-                        AttributeValueAssertion assertion = new AttributeValueAssertion();
-                        assertion.setAttributeDesc( ( ( ApproximateNode<?> ) exprNode
).getAttribute() );
-                        assertion.setAssertionValue( ( ( ApproximateNode<?> ) exprNode
).getValue() );
-                        ( ( AttributeValueAssertionFilter ) filter ).setAssertion( assertion
);
-                    }
-                }
-                else if ( exprNode instanceof SubstringNode )
-                {
-                    // Transform Substring Nodes
-                    filter = new SubstringFilter();
-
-                    ( ( SubstringFilter ) filter ).setType( ( ( SubstringNode ) exprNode
).getAttribute() );
-                    String initialString = ( ( SubstringNode ) exprNode ).getInitial();
-                    String finalString = ( ( SubstringNode ) exprNode ).getFinal();
-                    List<String> anyStrings = ( ( SubstringNode ) exprNode ).getAny();
-
-                    if ( initialString != null )
-                    {
-                        ( ( SubstringFilter ) filter ).setInitialSubstrings( initialString
);
-                    }
-
-                    if ( finalString != null )
-                    {
-                        ( ( SubstringFilter ) filter ).setFinalSubstrings( finalString );
-                    }
-
-                    if ( anyStrings != null )
-                    {
-                        for ( String any : anyStrings )
-                        {
-                            ( ( SubstringFilter ) filter ).addAnySubstrings( any );
-                        }
-                    }
-                }
-                else if ( exprNode instanceof ExtensibleNode )
-                {
-                    // Transform Extensible Node
-                    filter = new ExtensibleMatchFilter();
-
-                    String attribute = ( ( ExtensibleNode ) exprNode ).getAttribute();
-                    String matchingRule = ( ( ExtensibleNode ) exprNode ).getMatchingRuleId();
-                    boolean dnAttributes = ( ( ExtensibleNode ) exprNode ).hasDnAttributes();
-                    Value<?> value = ( ( ExtensibleNode ) exprNode ).getValue();
-
-                    if ( attribute != null )
-                    {
-                        ( ( ExtensibleMatchFilter ) filter ).setType( attribute );
-                    }
-
-                    if ( matchingRule != null )
-                    {
-                        ( ( ExtensibleMatchFilter ) filter ).setMatchingRule( matchingRule
);
-                    }
-
-                    ( ( ExtensibleMatchFilter ) filter ).setMatchValue( value );
-                    ( ( ExtensibleMatchFilter ) filter ).setDnAttributes( dnAttributes );
-                }
-            }
-
-            return filter;
-        }
-        else
-        {
-            // We have found nothing to transform. Return null then.
-            return null;
-        }
-    }
-
-
     /**
      * Transform the Codec message to a internal message.
      * 
@@ -367,51 +38,7 @@ public class LdapTransformer
      */
     public static Message transform( Object obj )
     {
-        if ( obj instanceof Message )
-        {
-            return ( Message ) obj;
-        }
-
-        LdapMessageCodec codecMessage = ( LdapMessageCodec ) obj;
-        int messageId = codecMessage.getMessageId();
-
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "Transforming LdapMessage <" + messageId + ", " + codecMessage.getMessageTypeName()
-                + "> from Codec to nternal." );
-        }
-
-        Message internalMessage = null;
-
-        MessageTypeEnum messageType = codecMessage.getMessageType();
-
-        switch ( messageType )
-        {
-            case SEARCH_REQUEST:
-            case MODIFY_REQUEST:
-            case MODIFYDN_REQUEST:
-            case EXTENDED_REQUEST:
-            case SEARCH_RESULT_ENTRY:
-            case SEARCH_RESULT_DONE:
-            case SEARCH_RESULT_REFERENCE:
-            case MODIFY_RESPONSE:
-            case ADD_RESPONSE:
-            case DEL_RESPONSE:
-            case MODIFYDN_RESPONSE:
-            case COMPARE_RESPONSE:
-            case EXTENDED_RESPONSE:
-            case INTERMEDIATE_RESPONSE:
-                // Nothing to do !
-                break;
-
-            default:
-                throw new IllegalStateException( I18n.err( I18n.ERR_04113 ) );
-        }
-
-        // Transform the controls, too
-        transformControlsCodecToInternal( codecMessage, internalMessage );
-
-        return internalMessage;
+        return ( Message ) obj;
     }
 
 
@@ -421,68 +48,8 @@ public class LdapTransformer
      * @param msg the message to transform
      * @return the msg transformed
      */
-    @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_ON_SOME_PATH", justification
= "The number of Ldap Message we are dealing with is finite, and we won't ever have to deal
with any other unexpected one")
     public static Object transform( Message msg )
     {
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "Transforming message type " + msg.getType() );
-        }
-
-        LdapMessageCodec codecMessage = null;
-
-        codecMessage.setMessageId( msg.getMessageId() );
-
-        // We also have to transform the controls...
-        if ( !msg.getControls().isEmpty() )
-        {
-            transformControlsInternalToCodec( codecMessage, msg );
-        }
-
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "Transformed message : " + codecMessage );
-        }
-
-        return codecMessage;
-    }
-
-
-    /**
-     * Copy the codec controls into the internal message
-     *
-     * @param codecMessage the Codec message
-     * @param msg the Internal message
-     */
-    private static void transformControlsCodecToInternal( LdapMessageCodec codecMessage,
Message internalMessage )
-    {
-        if ( codecMessage.getControls() == null )
-        {
-            return;
-        }
-
-        for ( final Control codecControl : codecMessage.getControls() )
-        {
-            internalMessage.addControl( codecControl );
-        }
-    }
-
-
-    /**
-     * Transforms the controls
-     * @param codecMessage The Codec SearchResultReference to produce
-     * @param msg The incoming Internal Message
-     */
-    private static void transformControlsInternalToCodec( LdapMessageCodec codecMessage,
Message internalMessage )
-    {
-        if ( internalMessage.getControls() == null )
-        {
-            return;
-        }
-
-        for ( Control control : internalMessage.getControls().values() )
-        {
-            codecMessage.addControl( control );
-        }
+        return msg;
     }
 }



Mime
View raw message