use of edu.internet2.middleware.grouperClient.api.GcFindGroups in project uPortal by Jasig.
the class GrouperEntityGroupStore method searchForGroups.
/* (non-Javadoc)
* @see org.apereo.portal.groups.IEntityGroupStore#searchForGroups(java.lang.String, int, java.lang.Class)
*/
public EntityIdentifier[] searchForGroups(final String query, final int method, @SuppressWarnings("unchecked") final Class leaftype) {
//only search for groups
if (leaftype != IPerson.class) {
return new EntityIdentifier[] {};
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Searching Grouper for groups matching query: " + query);
}
// result groups.
List<EntityIdentifier> groups = new ArrayList<EntityIdentifier>();
try {
// TODO: searches need to be performed against the group display
// name rather than the group key
GcFindGroups groupSearch = new GcFindGroups();
WsQueryFilter filter = new WsQueryFilter();
//is this an exact search or fuzzy
if (method == IGroupConstants.IS) {
filter.setQueryFilterType("FIND_BY_GROUP_NAME_EXACT");
} else {
filter.setQueryFilterType("FIND_BY_GROUP_NAME_APPROXIMATE");
}
filter.setGroupName(query);
groupSearch.assignQueryFilter(filter);
WsFindGroupsResults results = groupSearch.execute();
if (results != null && results.getGroupResults() != null) {
for (WsGroup g : results.getGroupResults()) {
if (validKey(g.getName())) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Retrieved group: " + g.getName());
}
groups.add(new EntityIdentifier(g.getName(), IEntityGroup.class));
}
}
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Returning " + groups.size() + " results for query " + query);
}
return groups.toArray(new EntityIdentifier[groups.size()]);
} catch (Exception e) {
LOGGER.warn("Exception while attempting to retrieve " + "search results for query " + query + " and entity type " + leaftype.getCanonicalName() + " : " + e.getMessage());
return new EntityIdentifier[] {};
}
}
use of edu.internet2.middleware.grouperClient.api.GcFindGroups in project uPortal by Jasig.
the class GrouperEntityGroupStore method findGroupFromKey.
/**
* Find the Grouper group matching the specified key.
*
* @param key
* @return the group or null
*/
protected WsGroup findGroupFromKey(String key) {
WsGroup wsGroup = null;
if (key != null) {
GcFindGroups gcFindGroups = new GcFindGroups();
gcFindGroups.addGroupName(key);
WsFindGroupsResults results = gcFindGroups.execute();
// if no results were returned, return null
if (results != null && results.getGroupResults() != null && results.getGroupResults().length > 0) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("found group from key " + key + ": " + results.getGroupResults()[0]);
}
wsGroup = results.getGroupResults()[0];
}
}
return wsGroup;
}
Aggregations