use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project cas by apereo.
the class GrouperFacadeTests method verifyAttributes.
@Test
public void verifyAttributes() {
val group = new WsGroup();
group.setExtension("GroupExtension");
group.setDisplayName("DisplayNameGroupExtension");
group.setDisplayExtension("DisplaySampleGroupExtension");
group.setDescription("Group Desc");
group.setName("SampleGroup");
group.setUuid(UUID.randomUUID().toString());
assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.DISPLAY_EXTENSION, group));
assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.DISPLAY_NAME, group));
assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.EXTENSION, group));
assertNotNull(GrouperFacade.getGrouperGroupAttribute(GrouperGroupField.NAME, group));
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uPortal by Jasig.
the class GrouperEntityGroupStore method find.
/* (non-Javadoc)
* @see org.apereo.portal.groups.IEntityGroupStore#find(java.lang.String)
*/
@Override
public IEntityGroup find(String key) throws GroupsException {
try {
// key
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Searching Grouper for a direct match for key: " + key);
}
WsGroup wsGroup = findGroupFromKey(key);
if (wsGroup == null) {
return null;
}
IEntityGroup group = createUportalGroupFromGrouperGroup(wsGroup);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Retrieved group from the Grouper server matching key " + key + ": " + group.toString());
}
// return the group
return group;
} catch (Exception e) {
LOGGER.warn("Exception while attempting to retrieve " + "group with key " + key + " from Grouper web services: " + e.getMessage());
return null;
}
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uPortal by Jasig.
the class GrouperEntityGroupStore method findMemberGroups.
@Override
@SuppressWarnings("unchecked")
public Iterator findMemberGroups(IEntityGroup group) throws GroupsException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Searching for group-type members of group with key: " + group.getKey());
}
try {
if (!validKey(group.getLocalKey())) {
return Collections.<IEntityGroup>emptyList().iterator();
}
GcGetMembers gcGetMembers = new GcGetMembers();
gcGetMembers.addGroupName(group.getLocalKey());
gcGetMembers.assignIncludeSubjectDetail(true);
gcGetMembers.addSourceId("g:gsa");
WsGetMembersResults results = gcGetMembers.execute();
if (results == null || results.getResults() == null || results.getResults().length == 0 || results.getResults()[0].getWsSubjects() == null) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("No group-type members found for group with key " + group.getKey());
}
return Collections.<IEntityGroup>emptyList().iterator();
}
final List<IEntityGroup> members = new ArrayList<IEntityGroup>();
WsSubject[] subjects = results.getResults()[0].getWsSubjects();
for (WsSubject wsSubject : subjects) {
if (validKey(wsSubject.getName())) {
WsGroup wsGroup = findGroupFromKey(wsSubject.getName());
if (wsGroup != null) {
IEntityGroup member = createUportalGroupFromGrouperGroup(wsGroup);
members.add(member);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("found IEntityGroup member: " + member);
}
}
}
}
return members.iterator();
} catch (Exception e) {
LOGGER.warn("Exception while attempting to retrieve " + "member groups of group with key " + group.getKey() + " from Grouper web services: " + e.getMessage());
return Collections.<IGroupMember>emptyList().iterator();
}
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup 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;
}
use of edu.internet2.middleware.grouperClient.ws.beans.WsGroup in project uPortal by Jasig.
the class GrouperEntityGroupStore method update.
/**
* @see IEntityGroupStore#update(IEntityGroup)
*/
@Override
public void update(IEntityGroup group) throws GroupsException {
// assume key is fully qualified group name
String groupName = group.getLocalKey();
String description = group.getDescription();
// the name is the displayExtension
String displayExtension = group.getName();
WsGroupToSave wsGroupToSave = new WsGroupToSave();
wsGroupToSave.setCreateParentStemsIfNotExist("T");
wsGroupToSave.setWsGroupLookup(new WsGroupLookup(groupName, null));
WsGroup wsGroup = new WsGroup();
wsGroup.setName(groupName);
wsGroup.setDisplayExtension(displayExtension);
wsGroup.setDescription(description);
wsGroupToSave.setWsGroup(wsGroup);
new GcGroupSave().addGroupToSave(wsGroupToSave).execute();
updateMembers(group);
}
Aggregations