use of org.jasig.services.persondir.IPersonAttributes in project uPortal by Jasig.
the class EntityPersonAttributesGroupStore method contains.
@Override
public boolean contains(IEntityGroup group, IGroupMember member) {
if (!IPERSON_CLASS.equals(member.getLeafType())) {
// group.getLeafType() is (presumably) IPerson.class.
return false;
}
if (member.isGroup()) {
// PAGS groups may only contain other PAGS groups (and people, of course)
final IEntityGroup ieg = (IEntityGroup) member;
if (!PagsService.SERVICE_NAME_PAGS.equals(ieg.getServiceName().toString())) {
return false;
}
}
final MembershipCacheKey cacheKey = new MembershipCacheKey(group.getEntityIdentifier(), member.getUnderlyingEntityIdentifier());
Element element = membershipCache.get(cacheKey);
if (element == null) {
logger.debug("Checking if group {} contains member {}/{}", group.getName(), member.getKey(), member.getLeafType().getSimpleName());
// default
boolean answer = false;
final PagsGroup groupDef = convertEntityToGroupDef(group);
if (member.isGroup()) {
final String key = ((IEntityGroup) member).getLocalKey();
answer = groupDef.hasMember(key);
} else {
try {
final IPersonAttributeDao pa = PersonAttributeDaoLocator.getPersonAttributeDao();
final IPersonAttributes personAttributes = pa.getPerson(member.getKey());
if (personAttributes != null) {
final RestrictedPerson rp = PersonFactory.createRestrictedPerson();
rp.setAttributes(personAttributes.getAttributes());
answer = groupDef.contains(rp);
}
} catch (Exception ex) {
logger.error("Exception acquiring attributes for member " + member + " while checking if group " + group + " contains this member.", ex);
return false;
}
}
element = new Element(cacheKey, answer);
membershipCache.put(element);
}
return (Boolean) element.getObjectValue();
}
use of org.jasig.services.persondir.IPersonAttributes in project uPortal by Jasig.
the class DirectoryPortletController method searchDirectory.
/**
* Search the directory for people matching the search query. Search results will be scoped to
* the permissions of the user performing the search.
*
* @param query
* @param request
* @return
*/
protected List<IPersonAttributes> searchDirectory(String query, PortletRequest request) {
final Map<String, Object> queryAttributes = new HashMap<String, Object>();
for (String attr : directoryQueryAttributes) {
queryAttributes.put(attr, query);
}
final List<IPersonAttributes> people;
// get an authorization principal for the current requesting user
HttpServletRequest servletRequest = portalRequestUtils.getPortletHttpRequest(request);
IPerson currentUser = personManager.getPerson(servletRequest);
// get the set of people matching the search query
people = this.lookupHelper.searchForPeople(currentUser, queryAttributes);
return people;
}
use of org.jasig.services.persondir.IPersonAttributes in project uPortal by Jasig.
the class DirectoryPortletController method findPersonByUsername.
@RenderMapping(params = "action=findByUsername")
public ModelAndView findPersonByUsername(RenderRequest request, @RequestParam String username) {
// get an authorization principal for the current requesting user
HttpServletRequest servletRequest = portalRequestUtils.getPortletHttpRequest(request);
IPerson currentUser = personManager.getPerson(servletRequest);
// get the set of people matching the search query
final IPersonAttributes person = this.lookupHelper.findPerson(currentUser, username);
final boolean isMobile = isMobile(request);
String viewName = isMobile ? "/jsp/Directory/mobileDirectory" : "/jsp/Directory/directory";
final Map<String, Object> model = new HashMap<String, Object>();
model.put("query", username);
model.put("people", Collections.singletonList(person));
model.put("attributeNames", this.displayAttributes);
return new ModelAndView(viewName, model);
}
Aggregations