Skip to content

Fix for #31 #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,21 @@ boolean authenticate(String base, String filter, String password,
*/
<T> List<T> findAll(Class<T> clazz);

/**
* Find all entries in the LDAP directory of a given type. The referenced class must have object-directory mapping metadata
* specified using {@link org.springframework.ldap.odm.annotations.Entry} and associated annotations.
*
* @param <T> The Java type to return
* @param base The root of the sub-tree at which to begin the search.
* @param clazz The Java type to return
* @return All entries that are of the type represented by the given
* Java class
*
* @throws org.springframework.ldap.NamingException on error.
* @since 2.0
*/
<T> List<T> findAll(Name base, Class<T> clazz);

/**
* Find all entries in the LDAP directory of a given type. The referenced class must have object-directory mapping metadata
* specified using {@link org.springframework.ldap.odm.annotations.Entry} and associated annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1812,10 +1812,19 @@ public <T> List<T> findAll(Name base, SearchControls searchControls, final Class
@Override
public <T> List<T> findAll(Class<T> clazz) {
return findAll(LdapUtils.emptyLdapName(),
getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES),
clazz);
}

/**
* {@inheritDoc}
*/
@Override
public <T> List<T> findAll(Name base, Class<T> clazz) {
return findAll(base,
getDefaultSearchControls(defaultSearchScope, RETURN_OBJ_FLAG, ALL_ATTRIBUTES),
clazz);
}

/**
* {@inheritDoc}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import com.mysema.query.support.QueryMixin;
import com.mysema.query.types.EntityPath;
import com.mysema.query.types.Predicate;

import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.query.LdapQuery;

import java.util.List;
Expand Down Expand Up @@ -69,7 +71,8 @@ public K uniqueResult() {
}

LdapQuery buildQuery() {
return query().filter(filterGenerator.handle(queryMixin.getMetadata().getWhere()));
String base = clazz.getAnnotation(Entry.class).base();
return query().base(base).filter(filterGenerator.handle(queryMixin.getMetadata().getWhere()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,22 @@
import org.springframework.ldap.core.LdapOperations;
import org.springframework.ldap.core.support.CountNameClassPairCallbackHandler;
import org.springframework.ldap.filter.Filter;
import org.springframework.ldap.odm.annotations.Entry;
import org.springframework.ldap.odm.core.ObjectDirectoryMapper;
import org.springframework.ldap.query.LdapQuery;
import org.springframework.ldap.repository.LdapRepository;
import org.springframework.ldap.support.LdapUtils;
import org.springframework.util.Assert;

import javax.naming.Name;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import static org.springframework.ldap.query.LdapQueryBuilder.query;


/**
* Base repository implementation for LDAP.
*
Expand Down Expand Up @@ -137,7 +141,8 @@ public boolean exists(Name name) {

@Override
public List<T> findAll() {
return ldapOperations.findAll(clazz);
String base = clazz.getAnnotation(Entry.class).base();
return ldapOperations.findAll(LdapUtils.newLdapName(base), clazz);
}

@Override
Expand Down