use of org.apereo.portal.groups.EntityTestingGroupImpl in project uPortal by Jasig.
the class EntityPersonAttributesGroupStore method convertPagsGroupToEntity.
private IEntityGroup convertPagsGroupToEntity(IPersonAttributesGroupDefinition group) {
final String cacheKey = group.getName();
Element element = entityGroupCache.get(cacheKey);
if (element == null) {
final IEntityGroup entityGroup = new EntityTestingGroupImpl(group.getName(), IPERSON_CLASS);
entityGroup.setName(group.getName());
entityGroup.setDescription(group.getDescription());
element = new Element(cacheKey, entityGroup);
entityGroupCache.put(element);
}
return (IEntityGroup) element.getObjectValue();
}
use of org.apereo.portal.groups.EntityTestingGroupImpl 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;
}
Aggregations