use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class GrouperEntityGroupStore method findMemberGroupKeys.
/* (non-Javadoc)
* @see org.apereo.portal.groups.IEntityGroupStore#findMemberGroupKeys(org.apereo.portal.groups.IEntityGroup)
*/
@SuppressWarnings("unchecked")
public String[] findMemberGroupKeys(IEntityGroup group) throws GroupsException {
// first the get an iterator for the member groups
final Iterator<IEntityGroup> it = findMemberGroups(group);
// construct a list of group keys from this iterator
List<String> keys = new ArrayList<String>();
while (it.hasNext()) {
IEntityGroup eg = it.next();
keys.add(eg.getKey());
}
// return an iterator over the assembled list
return keys.toArray(new String[keys.size()]);
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class GrouperEntityGroupStore method findMemberGroups.
@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 org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class PortletCategoryRegistryImpl method getPortletCategory.
/* (non-Javadoc)
* @see org.apereo.portal.portlet.registry.IPortletCategoryRegistry#getPortletCategory(java.lang.String)
*/
@Override
public PortletCategory getPortletCategory(String portletCategoryId) {
IEntityGroup categoryGroup = GroupService.findGroup(portletCategoryId);
if (categoryGroup == null) {
return null;
}
PortletCategory category = new PortletCategory(portletCategoryId);
category.setName(categoryGroup.getName());
category.setDescription(categoryGroup.getDescription());
category.setCreatorId(categoryGroup.getCreatorID());
return category;
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class SimpleAttributesMapper method mapFromAttributes.
/*
* Public API.
*/
public Object mapFromAttributes(Attributes attr) {
// Assertions.
if (keyAttributeName == null) {
String msg = "The property 'keyAttributeName' must be set.";
throw new IllegalStateException(msg);
}
if (groupNameAttributeName == null) {
String msg = "The property 'groupNameAttributeName' must be set.";
throw new IllegalStateException(msg);
}
if (membershipAttributeName == null) {
String msg = "The property 'membershipAttributeName' must be set.";
throw new IllegalStateException(msg);
}
if (log.isDebugEnabled()) {
String msg = "SimpleAttributesMapper.mapFromAttributes() :: settings: keyAttributeName='" + keyAttributeName + "', groupNameAttributeName='" + groupNameAttributeName + "', groupNameAttributeName='" + groupNameAttributeName + "'";
log.debug(msg);
}
LdapRecord rslt;
try {
String key = (String) attr.get(keyAttributeName).get();
String groupName = (String) attr.get(groupNameAttributeName).get();
IEntityGroup g = new EntityTestingGroupImpl(key, IPerson.class);
g.setCreatorID("System");
g.setName(groupName);
g.setDescription(GROUP_DESCRIPTION);
List<String> membership = new LinkedList<String>();
Attribute m = attr.get(membershipAttributeName);
if (m != null) {
for (Enumeration<?> en = m.getAll(); en.hasMoreElements(); ) {
membership.add((String) en.nextElement());
}
}
rslt = new LdapRecord(g, membership);
if (log.isDebugEnabled()) {
StringBuilder msg = new StringBuilder();
msg.append("Record Details:").append("\n\tkey=").append(key).append("\n\tgroupName=").append(groupName).append("\n\tmembers:");
for (String s : membership) {
msg.append("\n\t\t").append(s);
}
log.debug(msg.toString());
}
} catch (Throwable t) {
log.error("Error in SimpleAttributesMapper", t);
String msg = "SimpleAttributesMapper failed to create a LdapRecord " + "from the specified Attributes: " + attr;
throw new RuntimeException(msg, t);
}
return rslt;
}
use of org.apereo.portal.groups.IEntityGroup in project uPortal by Jasig.
the class JpaEventAggregationManagementDaoTest method testAggregatedGroupConfig.
@Test
public void testAggregatedGroupConfig() throws Exception {
final IEntityGroup everyoneGroup = mock(IEntityGroup.class);
when(everyoneGroup.getServiceName()).thenReturn(new CompositeName("local"));
when(everyoneGroup.getName()).thenReturn("Everyone");
when(compositeGroupService.findGroup("local.0")).thenReturn(everyoneGroup);
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNull(loginAggregatedGroupConfig);
loginAggregatedGroupConfig = eventAggregationManagementDao.createAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNotNull(loginAggregatedGroupConfig);
assertEquals(0, loginAggregatedGroupConfig.getExcluded().size());
assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
final AggregatedGroupMapping group = aggregatedGroupLookupDao.getGroupMapping("local.0");
defaultAggregatedGroupConfig.getIncluded().add(group);
loginAggregatedGroupConfig.getExcluded().add(group);
eventAggregationManagementDao.updateAggregatedGroupConfig(defaultAggregatedGroupConfig);
eventAggregationManagementDao.updateAggregatedGroupConfig(loginAggregatedGroupConfig);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(1, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNotNull(loginAggregatedGroupConfig);
assertEquals(1, loginAggregatedGroupConfig.getExcluded().size());
assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
eventAggregationManagementDao.deleteAggregatedGroupConfig(defaultAggregatedGroupConfig);
eventAggregationManagementDao.deleteAggregatedGroupConfig(loginAggregatedGroupConfig);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNull(loginAggregatedGroupConfig);
}
});
}
Aggregations