* @see org.jasig.portal.layout.dlm.remoting.IGroupListHelper#getEntity(java.lang.String, java.lang.String, boolean)
*/
public JsonEntityBean getEntity(String entityType, String entityId, boolean populateChildren) {
// get the EntityEnum for the specified entity type
EntityEnum entityEnum = EntityEnum.getEntityEnum(entityType);
// if the entity type is a group, use the group service's findGroup method
// to locate it
if(entityEnum.isGroup()) {
// attempt to find the entity
IEntityGroup entity = GroupService.findGroup(entityId);
if(entity == null) {
return null;
} else {
JsonEntityBean jsonBean = new JsonEntityBean(entity, entityEnum.toString());
if (populateChildren) {
@SuppressWarnings("unchecked")
Iterator<IGroupMember> members = (Iterator<IGroupMember>) entity.getMembers();
jsonBean = populateChildren(jsonBean, members);
}
return jsonBean;
}
}
// otherwise use the getGroupMember method
else {
IGroupMember entity = GroupService.getGroupMember(entityId, entityEnum.getClazz());
if(entity == null || entity instanceof IEntityGroup) {
return null;
}
JsonEntityBean jsonBean = new JsonEntityBean(entity, entityEnum.toString());
// the group member interface doesn't include the entity name, so
// we'll need to look that up manually
jsonBean.setName(lookupEntityName(jsonBean));
return jsonBean;