From 3686b7987e4d27dc1ba5de747d5ce545699579b5 Mon Sep 17 00:00:00 2001 From: Mattias Hellborg Arthursson Date: Wed, 25 Sep 2013 11:04:36 +0200 Subject: [PATCH] LDAP-263: Minor tweak to sample; use LdapQuery wherever possible. --- .../ldap/samples/plain/dao/PersonDaoImpl.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/samples/plain/src/main/java/org/springframework/ldap/samples/plain/dao/PersonDaoImpl.java b/samples/plain/src/main/java/org/springframework/ldap/samples/plain/dao/PersonDaoImpl.java index b1e917ec..1814d19c 100644 --- a/samples/plain/src/main/java/org/springframework/ldap/samples/plain/dao/PersonDaoImpl.java +++ b/samples/plain/src/main/java/org/springframework/ldap/samples/plain/dao/PersonDaoImpl.java @@ -21,7 +21,6 @@ import org.springframework.ldap.core.DirContextAdapter; import org.springframework.ldap.core.DirContextOperations; import org.springframework.ldap.core.LdapTemplate; import org.springframework.ldap.core.support.AbstractContextMapper; -import org.springframework.ldap.filter.EqualsFilter; import org.springframework.ldap.samples.plain.domain.Person; import org.springframework.ldap.support.LdapNameBuilder; import org.springframework.ldap.support.LdapUtils; @@ -76,13 +75,15 @@ public class PersonDaoImpl implements PersonDao { @Override public List getAllPersonNames() { - EqualsFilter filter = new EqualsFilter("objectclass", "person"); - return ldapTemplate.search(LdapUtils.emptyLdapName(), filter.encode(), new AttributesMapper() { - public String mapFromAttributes(Attributes attrs) throws NamingException { - return attrs.get("cn").get().toString(); - } - }); - } + return ldapTemplate.search(query() + .attributes("cn") + .where("objectclass").is("person"), + new AttributesMapper() { + public String mapFromAttributes(Attributes attrs) throws NamingException { + return attrs.get("cn").get().toString(); + } + }); + } @Override public List findAll() {