Search in sources :

Example 1 with WsFindGroupsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults in project uhgroupings by uhawaii-system-its-ti-iam.

the class GroupingFactoryServiceImpl method getGroupId.

// returns the uid for a group in grouper
private String getGroupId(String groupPath) {
    WsFindGroupsResults results = grouperFactoryService.makeWsFindGroupsResults(groupPath);
    WsGroup result = results.getGroupResults()[0];
    return result.getUuid();
}
Also used : WsFindGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Example 2 with WsFindGroupsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults 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[] {};
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) WsQueryFilter(edu.internet2.middleware.grouperClient.ws.beans.WsQueryFilter) WsFindGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults) GcFindGroups(edu.internet2.middleware.grouperClient.api.GcFindGroups) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) EntityIdentifier(org.apereo.portal.EntityIdentifier) GroupsException(org.apereo.portal.groups.GroupsException)

Example 3 with WsFindGroupsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults 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)
     */
@Override
public EntityIdentifier[] searchForGroups(final String query, final SearchMethod 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 == SearchMethod.DISCRETE_CI) || (method == SearchMethod.DISCRETE)) {
            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[] {};
    }
}
Also used : IEntityGroup(org.apereo.portal.groups.IEntityGroup) WsQueryFilter(edu.internet2.middleware.grouperClient.ws.beans.WsQueryFilter) WsFindGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults) GcFindGroups(edu.internet2.middleware.grouperClient.api.GcFindGroups) ArrayList(java.util.ArrayList) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup) EntityIdentifier(org.apereo.portal.EntityIdentifier) GroupsException(org.apereo.portal.groups.GroupsException)

Example 4 with WsFindGroupsResults

use of edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults 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;
}
Also used : WsFindGroupsResults(edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults) GcFindGroups(edu.internet2.middleware.grouperClient.api.GcFindGroups) WsGroup(edu.internet2.middleware.grouperClient.ws.beans.WsGroup)

Aggregations

WsFindGroupsResults (edu.internet2.middleware.grouperClient.ws.beans.WsFindGroupsResults)4 WsGroup (edu.internet2.middleware.grouperClient.ws.beans.WsGroup)4 GcFindGroups (edu.internet2.middleware.grouperClient.api.GcFindGroups)3 WsQueryFilter (edu.internet2.middleware.grouperClient.ws.beans.WsQueryFilter)2 ArrayList (java.util.ArrayList)2 EntityIdentifier (org.apereo.portal.EntityIdentifier)2 GroupsException (org.apereo.portal.groups.GroupsException)2 IEntityGroup (org.apereo.portal.groups.IEntityGroup)2