Commit 3a538417 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Throw GroupNotFoundException when the specified group is not found. JM-490

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@3191 b35dd754-fafc-0310-a699-88a17e54d16e
parent 2c033d15
......@@ -14,6 +14,7 @@ package org.jivesoftware.messenger.ldap;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.group.Group;
import org.jivesoftware.messenger.group.GroupProvider;
import org.jivesoftware.messenger.group.GroupNotFoundException;
import org.jivesoftware.messenger.user.UserManager;
import org.jivesoftware.messenger.user.UserNotFoundException;
import org.jivesoftware.util.JiveConstants;
......@@ -77,18 +78,19 @@ public class LdapGroupProvider implements GroupProvider {
throw new UnsupportedOperationException();
}
public Group getGroup(String group) {
public Group getGroup(String group) throws GroupNotFoundException {
String filter = MessageFormat.format(manager.getGroupSearchFilter(), "*");
String searchFilter = "(&" + filter + "(" +
manager.getGroupNameField() + "=" + group + "))";
Collection<Group> groups = populateGroups(searchForGroups(searchFilter, standardAttributes));
if (groups.size() > 1) {
return null; //if multiple groups found return null
//if multiple groups found throw exception
throw new GroupNotFoundException("Too many groups with name " + group + " were found.");
}
for (Group g : groups) {
return g; //returns the first group found
}
return null;
throw new GroupNotFoundException("Group with name " + group + " not found.");
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment