From 19ebc3e17192e82cc9323ecdf2df76a34d4ba210 Mon Sep 17 00:00:00 2001 From: Ulrik Sandberg Date: Fri, 12 Jan 2007 16:20:56 +0000 Subject: [PATCH] IN PROGRESS - issue LDAP-4: Translate LDAP error codes http://opensource.atlassian.com/projects/spring/browse/LDAP-4 --- .../samples/person/dao/PersonContextMapper.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/spring-ldap-person/src/main/java/org/springframework/ldap/samples/person/dao/PersonContextMapper.java b/spring-ldap-person/src/main/java/org/springframework/ldap/samples/person/dao/PersonContextMapper.java index 132254aa..84df3488 100644 --- a/spring-ldap-person/src/main/java/org/springframework/ldap/samples/person/dao/PersonContextMapper.java +++ b/spring-ldap-person/src/main/java/org/springframework/ldap/samples/person/dao/PersonContextMapper.java @@ -21,9 +21,7 @@ import org.springframework.ldap.core.ContextMapper; import org.springframework.ldap.core.DirContextOperations; import org.springframework.ldap.core.DistinguishedName; import org.springframework.ldap.samples.person.domain.Person; -import org.springframework.ldap.support.DefaultNamingExceptionTranslator; -import org.springframework.ldap.support.NamingExceptionTranslator; -import org.springframework.util.Assert; +import org.springframework.ldap.support.LdapUtils; /** * Maps from DirContextOperations (DirContextAdapters, really) to Person @@ -37,17 +35,14 @@ import org.springframework.util.Assert; */ public class PersonContextMapper implements ContextMapper { - private NamingExceptionTranslator exceptionTranslator = new DefaultNamingExceptionTranslator(); - public Object mapFromContext(Object ctx) { - Assert.notNull(exceptionTranslator, "exceptionTranslator must be set"); DirContextOperations dirContext = (DirContextOperations) ctx; DistinguishedName dn = new DistinguishedName(dirContext.getDn()); String fullDn; try { fullDn = dirContext.getNameInNamespace(); } catch (NamingException e) { - throw exceptionTranslator.translate(e); + throw LdapUtils.convertLdapException(e); } Person person = new Person(); person.setDn(fullDn); @@ -60,9 +55,4 @@ public class PersonContextMapper implements ContextMapper { return person; } - - public void setExceptionTranslator( - NamingExceptionTranslator exceptionTranslator) { - this.exceptionTranslator = exceptionTranslator; - } }