You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2004/06/25 06:45:39 UTC
svn commit: rev 22100 - in incubator/directory/eve/branches/start: . src/java/org/apache/eve/protocol
Author: akarasulu
Date: Thu Jun 24 21:45:39 2004
New Revision: 22100
Modified:
incubator/directory/eve/branches/start/ (props changed)
incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/CompareHandler.java
Log:
switched to using JNDI provider
Modified: incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/CompareHandler.java
==============================================================================
--- incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/CompareHandler.java (original)
+++ incubator/directory/eve/branches/start/src/java/org/apache/eve/protocol/CompareHandler.java Thu Jun 24 21:45:39 2004
@@ -21,6 +21,11 @@
import javax.naming.Name;
import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.Attribute;
+import javax.naming.ldap.LdapContext;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
@@ -111,8 +116,6 @@
{
Name dn = null;
Schema schema = null;
- LdapEntry entry = null;
- Backend be = null;
Logger log = m_module.getLogger();
CompareRequest req = ( CompareRequest ) a_request;
CompareResponseImpl resp;
@@ -153,13 +156,16 @@
throw new CascadingRuntimeException( msg, e );
}
+ Attributes attrs;
try
{
- be = m_module.getNexus().getBackend( dn ) ;
+ InitialContext initCtx = Utils.getInitialContext() ;
+ LdapContext ctx = ( LdapContext ) initCtx.lookup( req.getName() ) ;
+ attrs = ctx.getAttributes( "" );
}
catch ( NamingException e )
{
- String msg = "failed to resolve backend for " + req.getName();
+ String msg = "failed to lookup entry " + req.getName();
if ( log.isErrorEnabled() )
{
@@ -169,13 +175,23 @@
throw new CascadingRuntimeException( msg, e );
}
+ Attribute attr = attrs.get( req.getAttributeId() );
+ if ( attr == null )
+ {
+ result.setMatchedDn(req.getName());
+ result.setResultCode(ResultCodeEnum.COMPAREFALSE);
+ return resp;
+ }
+
+ NamingEnumeration list;
try
{
- entry = be.read( dn );
+ list = attr.getAll();
}
- catch ( Exception e )
+ catch ( NamingException e )
{
- String msg = "failed to read entry for " + req.getName();
+ String msg = "failed to lookup attribute values for id " +
+ req.getAttributeId() + " in entry " + req.getName();
if ( log.isErrorEnabled() )
{
@@ -185,13 +201,11 @@
throw new CascadingRuntimeException( msg, e );
}
- Iterator list;
- list = entry.getMultiValue( req.getAttributeId() ).iterator();
- String compareTo = req.getAssertionValue();
+ String compareTo = req.getAssertionValue();
try
{
- while( list.hasNext() )
+ while( list.hasMore() )
{
String value = ( String ) list.next();
value = schema.normalize( req.getAttributeId(), value );
@@ -214,7 +228,7 @@
throw new CascadingRuntimeException( msg, e );
}
- result.setMatchedDn( entry.getEntryDN() );
+ result.setMatchedDn( req.getName() );
return resp ;
}
}