directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r231083 - in /directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol: AddHandler.java BindHandler.java CompareHandler.java DeleteHandler.java ModifyDnHandler.java ModifyHandler.java SearchHandler.java
Date Tue, 09 Aug 2005 19:08:36 GMT
Author: akarasulu
Date: Tue Aug  9 12:08:30 2005
New Revision: 231083

URL: http://svn.apache.org/viewcvs?rev=231083&view=rev
Log:
I had incorrectly demonstrated by example to stefan the user of nlog4j directly
rather than using the slf4j loggers.  I corrected this in the classes his patch
altered.  I also did a little formatting to remove the extra spaces I had 
injected while experimenting with a new code style: backing out of that now 
after some complaints.

Modified:
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AddHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/DeleteHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyDnHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
    directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SearchHandler.java

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AddHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AddHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AddHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/AddHandler.java
Tue Aug  9 12:08:30 2005
@@ -28,7 +28,10 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
-import org.apache.log4j.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 /**
  * A single reply handler for {@link org.apache.ldap.common.message.AddRequest}s.
@@ -38,20 +41,17 @@
  */
 public class AddHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( AddHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( AddHandler.class );
 
     public void messageReceived( ProtocolSession session, Object request )
     {
         AddRequest req = ( AddRequest ) request;
-
         AddResponse resp = new AddResponseImpl( req.getMessageId() );
-
         resp.setLdapResult( new LdapResultImpl( resp ) );
 
         try
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
-
             ctx.createSubcontext( req.getName(), req.getEntry() );
         }
         catch( NamingException e )
@@ -75,9 +75,7 @@
             }
 
             resp.getLdapResult().setResultCode( code );
-
             resp.getLdapResult().setErrorMessage( msg );
-
             if( e.getResolvedName() != null )
             {
                 resp.getLdapResult().setMatchedDn(
@@ -85,14 +83,11 @@
             }
 
             session.write( resp );
-
             return;
         }
 
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-
         resp.getLdapResult().setMatchedDn( req.getName() );
-
         session.write( resp );
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/BindHandler.java
Tue Aug  9 12:08:30 2005
@@ -34,7 +34,6 @@
 import org.apache.ldap.common.message.LdapResultImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
-import org.apache.log4j.Logger;
 
 /*
  * I would like to eventually see these newly introduced dependencies
@@ -52,6 +51,9 @@
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 
 
 /**
@@ -62,21 +64,16 @@
  */
 public class BindHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( BindHandler.class );
-
+    private static final Logger LOG = LoggerFactory.getLogger( BindHandler.class );
     private static final Control[] EMPTY = new Control[0];
 
 
     public void messageReceived( ProtocolSession session, Object request )
     {
         LdapContext ctx;
-
         BindRequest req = ( BindRequest ) request;
-
         BindResponse resp = new BindResponseImpl( req.getMessageId() );
-
         LdapResult result = new LdapResultImpl( resp );
-
         resp.setLdapResult( result );
 
         Hashtable env = SessionRegistry.getSingleton().getEnvironment();
@@ -85,11 +82,8 @@
         if ( ! req.isSimple() )
         {
             result.setResultCode( ResultCodeEnum.AUTHMETHODNOTSUPPORTED );
-
             result.setErrorMessage( "Only simple binds currently supported" );
-
             session.write( resp );
-
             return;
         }
 
@@ -100,13 +94,9 @@
         if ( emptyCredentials && emptyDn && ! allowAnonymousBinds )
         {
             result.setResultCode( ResultCodeEnum.INSUFFICIENTACCESSRIGHTS );
-
             String msg = "Bind failure: Anonymous binds have been disabled!";
-
             result.setErrorMessage( msg );
-
             session.write( resp );
-
             return;
         }
 
@@ -163,18 +153,13 @@
 
 
             result.setErrorMessage( msg );
-
             session.write( resp );
-
             return;
         }
 
         SessionRegistry.getSingleton().setLdapContext( session, ctx );
-
         result.setResultCode( ResultCodeEnum.SUCCESS );
-
         result.setMatchedDn( req.getName() );
-
         session.write( resp );
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/CompareHandler.java
Tue Aug  9 12:08:30 2005
@@ -30,7 +30,8 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
-import org.apache.log4j.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -41,20 +42,17 @@
  */
 public class CompareHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( CompareHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( CompareHandler.class );
 
     public void messageReceived( ProtocolSession session, Object request )
     {
         CompareRequest req = ( CompareRequest ) request;
-
         CompareResponse resp = new CompareResponseImpl( req.getMessageId() );
-
         resp.setLdapResult( new LdapResultImpl( resp ) );
 
         try
         {
             DirContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
-
             Attribute attr = ctx.getAttributes( req.getName() ).get( req.getAttributeId()
);
 
             if ( attr == null )
@@ -80,7 +78,6 @@
             }
 
             ResultCodeEnum code;
-
             if ( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode() ;
@@ -91,7 +88,6 @@
             }
 
             resp.getLdapResult().setResultCode( code );
-
             resp.getLdapResult().setErrorMessage( msg );
 
             if ( e.getResolvedName() != null )
@@ -100,12 +96,10 @@
             }
 
             session.write( resp );
-
             return;
         }
 
         resp.getLdapResult().setMatchedDn( req.getName() );
-
         session.write( resp );
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/DeleteHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/DeleteHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/DeleteHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/DeleteHandler.java
Tue Aug  9 12:08:30 2005
@@ -28,7 +28,10 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
-import org.apache.log4j.Logger;
+
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
+
 
 /**
  * A single reply handler for {@link org.apache.ldap.common.message.DeleteRequest}s.
@@ -38,7 +41,7 @@
  */
 public class DeleteHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( DeleteHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( DeleteHandler.class );
 
 
     public void messageReceived( ProtocolSession session, Object request )

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyDnHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyDnHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyDnHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyDnHandler.java
Tue Aug  9 12:08:30 2005
@@ -30,7 +30,9 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
-import org.apache.log4j.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -41,28 +43,23 @@
  */
 public class ModifyDnHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( ModifyDnHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( ModifyDnHandler.class );
 
     public void messageReceived( ProtocolSession session, Object request )
     {
         ModifyDnRequest req = ( ModifyDnRequest ) request;
-
         ModifyDnResponse resp = new ModifyDnResponseImpl( req.getMessageId() );
-
         resp.setLdapResult( new LdapResultImpl( resp ) );
 
         try
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
-
             String deleteRDN = String.valueOf( req.getDeleteOldRdn() );
-
             ctx.addToEnvironment( "java.naming.ldap.deleteRDN", deleteRDN );
 
             if ( req.isMove() )
             {
                 LdapName oldDn = new LdapName( req.getName() );
-
                 LdapName newDn = new LdapName( req.getNewSuperior() );
 
                 if ( req.getNewRdn() != null )
@@ -79,11 +76,8 @@
             else
             {
                 LdapName newDn = new LdapName( req.getName() );
-
                 newDn.remove( newDn.size() - 1 );
-
                 newDn.add( req.getNewRdn() );
-
                 ctx.rename( new LdapName( req.getName() ), newDn );
             }
         }
@@ -97,7 +91,6 @@
             }
 
             ResultCodeEnum code;
-
             if ( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode() ;
@@ -108,7 +101,6 @@
             }
 
             resp.getLdapResult().setResultCode( code );
-
             resp.getLdapResult().setErrorMessage( msg );
 
             if ( e.getResolvedName() != null )
@@ -117,14 +109,11 @@
             }
 
             session.write( resp );
-
             return;
         }
 
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-
         resp.getLdapResult().setMatchedDn( req.getName() );
-
         session.write( resp );
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/ModifyHandler.java
Tue Aug  9 12:08:30 2005
@@ -30,7 +30,9 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
-import org.apache.log4j.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -41,24 +43,20 @@
  */
 public class ModifyHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( ModifyHandler.class );
-
+    private static final Logger LOG = LoggerFactory.getLogger( ModifyHandler.class );
     private static final ModificationItem[] EMPTY = new ModificationItem[0];
 
+
     public void messageReceived( ProtocolSession session, Object request )
     {
         ModifyRequest req = ( ModifyRequest ) request;
-
         ModifyResponse resp = new ModifyResponseImpl( req.getMessageId() );
-
         resp.setLdapResult( new LdapResultImpl( resp ) );
 
         try
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null,
true );
-
             Object[] mods = req.getModificationItems().toArray( EMPTY );
-
             ctx.modifyAttributes( req.getName(), ( ModificationItem[] ) mods );
         }
         catch ( NamingException e )
@@ -71,7 +69,6 @@
             }
 
             ResultCodeEnum code;
-
             if ( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode() ;
@@ -82,7 +79,6 @@
             }
 
             resp.getLdapResult().setResultCode( code );
-
             resp.getLdapResult().setErrorMessage( msg );
 
             if ( e.getResolvedName() != null )
@@ -91,16 +87,12 @@
             }
 
             session.write( resp );
-
             return;
         }
 
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-
         resp.getLdapResult().setMatchedDn( req.getName() );
-
         session.write( resp );
-
         return;
     }
 }

Modified: directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SearchHandler.java
URL: http://svn.apache.org/viewcvs/directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SearchHandler.java?rev=231083&r1=231082&r2=231083&view=diff
==============================================================================
--- directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SearchHandler.java
(original)
+++ directory/protocol-providers/ldap/trunk/src/main/java/org/apache/ldap/server/protocol/SearchHandler.java
Tue Aug  9 12:08:30 2005
@@ -44,7 +44,9 @@
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.handler.MessageHandler;
-import org.apache.log4j.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A handler for processing search requests.
@@ -54,31 +56,24 @@
  */
 public class SearchHandler implements MessageHandler
 {
-    private static final Logger LOG = Logger.getLogger( SearchHandler.class );
-    
+    private static final Logger LOG = LoggerFactory.getLogger( SearchHandler.class );
     private static final String DEREFALIASES_KEY = "java.naming.ldap.derefAliases";
 
 
     public void messageReceived( ProtocolSession session, Object request )
     {
         LdapContext ctx;
-
         SearchRequest req = ( SearchRequest ) request;
-
         NamingEnumeration list = null;
 
         // check the attributes to see if a referral's ref attribute is included
-
         String[] ids = null;
-
         Collection retAttrs = new HashSet();
-
         retAttrs.addAll( req.getAttributes() );
 
         if( retAttrs.size() > 0 && !retAttrs.contains( "ref" ) )
         {
             retAttrs.add( "ref" );
-
             ids = ( String[] ) retAttrs.toArray( ArrayUtils.EMPTY_STRING_ARRAY );
         }
         else if( retAttrs.size() > 0 )
@@ -87,25 +82,17 @@
         }
 
         // prepare all the search controls
-
         SearchControls controls = new SearchControls();
-
         controls.setCountLimit( req.getSizeLimit() );
-
         controls.setTimeLimit( req.getTimeLimit() );
-
         controls.setSearchScope( req.getScope().getValue() );
-
         controls.setReturningObjFlag( req.getTypesOnly() );
-
         controls.setReturningAttributes( ids );
-
         controls.setDerefLinkFlag( true );
 
         try
         {
             ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-
             ctx.addToEnvironment( DEREFALIASES_KEY, req.getDerefAliases().getName() );
 
             /*
@@ -125,15 +112,12 @@
              * the filter.
              */
             ctx.addToEnvironment( "__filter__", req.getFilter() );
-
             list = ctx.search( req.getBase(), null, controls );
-
             ctx.removeFromEnvironment( "__filter__" );
 
             if( list.hasMore() )
             {
                 Iterator it = new SearchResponseIterator( req, list );
-
                 while( it.hasNext() )
                 {
                     session.write( it.next() );
@@ -144,15 +128,10 @@
             else
             {
                 list.close();
-
                 SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId()
);
-
                 resp.setLdapResult( new LdapResultImpl( resp ) );
-
                 resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-
                 resp.getLdapResult().setMatchedDn( req.getBase() );
-
                 Iterator it = Collections.singleton( resp ).iterator();
 
                 while( it.hasNext() )
@@ -173,7 +152,6 @@
             }
 
             SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId() );
-
             ResultCodeEnum rc = null;
 
             if( e instanceof LdapException )
@@ -186,9 +164,7 @@
             }
 
             resp.setLdapResult( new LdapResultImpl( resp ) );
-
             resp.getLdapResult().setResultCode( rc );
-
             resp.getLdapResult().setErrorMessage( msg );
 
             if( e.getResolvedName() != null )



Mime
View raw message