Skip to content

Commit

Permalink
Merge pull request #11 from bonhamcm/master
Browse files Browse the repository at this point in the history
Changed to NullSearchImpl when user uid is star since no users were retu...
  • Loading branch information
dwimberger committed Dec 17, 2013
2 parents f2a1c70 + b12fe56 commit 2e6b115
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/net/wimpi/crowd/ldap/CrowdPartition.java
@@ -1,12 +1,14 @@
package net.wimpi.crowd.ldap;

import com.atlassian.crowd.embedded.api.SearchRestriction;
import com.atlassian.crowd.exception.ApplicationPermissionException;
import com.atlassian.crowd.exception.InvalidAuthenticationException;
import com.atlassian.crowd.exception.OperationFailedException;
import com.atlassian.crowd.exception.UserNotFoundException;
import com.atlassian.crowd.model.group.Group;
import com.atlassian.crowd.model.user.User;
import com.atlassian.crowd.search.query.entity.restriction.MatchMode;
import com.atlassian.crowd.search.query.entity.restriction.NullRestrictionImpl;
import com.atlassian.crowd.search.query.entity.restriction.TermRestriction;
import com.atlassian.crowd.search.query.entity.restriction.constants.GroupTermKeys;
import com.atlassian.crowd.search.query.entity.restriction.constants.UserTermKeys;
Expand Down Expand Up @@ -417,7 +419,7 @@ private BaseEntryFilteringCursor findObject(SearchingOperationContext ctx) {
String dnName = dn.getName();
ServerEntry se = ctx.getEntry();

log.debug("findObject()::dn=" + dn.getName() + "::entry=" + se.toString());
log.debug("findObject()::dn=" + dnName + "::entry=" + se.toString());

//1. Try cache
se = m_EntryCache.get(dn.getName());
Expand Down Expand Up @@ -456,7 +458,7 @@ private BaseEntryFilteringCursor findOneLevel(SearchOperationContext ctx) {

List<ServerEntry> l = new ArrayList<ServerEntry>();
try {
TermRestriction groupName = new TermRestriction(GroupTermKeys.NAME, MatchMode.CONTAINS, "");
TermRestriction<String> groupName = new TermRestriction<String>(GroupTermKeys.NAME, MatchMode.CONTAINS, "");
List<String> list = m_CrowdClient.searchGroupNames(groupName, 0, Integer.MAX_VALUE);
for (String gn : list) {
DN gdn = new DN(String.format("dn=%s,%s", gn, CROWD_GROUPS_DN));
Expand Down Expand Up @@ -487,7 +489,14 @@ private BaseEntryFilteringCursor findOneLevel(SearchOperationContext ctx) {

List<ServerEntry> l = new ArrayList<ServerEntry>();
try {
TermRestriction userName = new TermRestriction(UserTermKeys.USERNAME, MatchMode.CONTAINS, uid);
SearchRestriction userName = null;
if ("*".equals(uid)) {
// Contains * term restriction does not return any users, so use null one
userName = NullRestrictionImpl.INSTANCE;

} else {
userName = new TermRestriction<String>(UserTermKeys.USERNAME, MatchMode.CONTAINS, uid);
}
List<String> list = m_CrowdClient.searchUserNames(userName, 0, Integer.MAX_VALUE);
for (String gn : list) {
DN udn = new DN(String.format("dn=%s,%s", gn, CROWD_USERS_DN));
Expand Down

0 comments on commit 2e6b115

Please sign in to comment.