/** * Instantiates the static singleton field PERSON_DIR_NAME_FINDER_INSTANCE. Synchronized to * guarantee singleton-ness of the field. */ private static synchronized void storeSingleton() { // recheck that we need to run because field could have been // set since we decided to invoke this method but before we acquired // the lock on this object if (PERSON_DIR_NAME_FINDER_INSTANCE == null) { IPersonAttributeDao personAttributeDao = PersonAttributeDaoLocator.getPersonAttributeDao(); PERSON_DIR_NAME_FINDER_INSTANCE = new PersonDirNameFinder(personAttributeDao); } }
@Override public boolean contains(IEntityGroup group, IGroupMember member) { /* * This method has the potential to be called A LOT, especially if * there's a lot of portal data (portlets & groups). It's important * not to waste time on nonsensical checks. */ if (!IPERSON_CLASS.equals(member.getLeafType())) { // Maybe this call to contains() shouldn't even happen, since // 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.getEntityIdentifier()); Element element = membershipCache.get(cacheKey); if (element == null) { logger.debug( "Checking if group {} contains member {}/{}", group.getName(), member.getKey(), member.getLeafType().getSimpleName()); boolean answer = false; // default 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(); }