@Test public void applyOverridesIfPresentTest() { final Map<String, List<Object>> attributes = Collections.singletonMap( CUSTOMARY_FIRST_NAME_ATTRIBUTE, Collections.singletonList(FIRST_NAME)); final IPersonAttributes person = new NamedPersonImpl(USERNAME, attributes); portalRootPersonAttributeDao.setUserAttributeOverride( "somebody.else", Collections.singletonMap(CUSTOMARY_FIRST_NAME_ATTRIBUTE, "something")); final IPersonAttributes rsltWithout = portalRootPersonAttributeDao.applyOverridesIfPresent(person); Assert.assertEquals( FIRST_NAME, rsltWithout.getAttributeValue(CUSTOMARY_FIRST_NAME_ATTRIBUTE)); final String overriddenFirstName = "Nebby"; portalRootPersonAttributeDao.setUserAttributeOverride( USERNAME, Collections.singletonMap(CUSTOMARY_FIRST_NAME_ATTRIBUTE, overriddenFirstName)); final IPersonAttributes rsltWith = portalRootPersonAttributeDao.applyOverridesIfPresent(person); Assert.assertEquals( overriddenFirstName, rsltWith.getAttributeValue(CUSTOMARY_FIRST_NAME_ATTRIBUTE)); }
protected IPersonAttributes applyOverridesIfPresent(IPersonAttributes person) { IPersonAttributes rslt = person; final Map<String, List<Object>> overrides = overridesMap.get(person.getName()); if (overrides != null) { logger.debug( "Overriding the following collection of attributes for user '{}': {}", person.getName(), overrides); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); final Map<String, List<Object>> mergedAttributes = attributeMerger.mergeAttributes(mutableMap, overrides); rslt = new NamedPersonImpl(person.getName(), mergedAttributes); } return rslt; }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes applyOverridesIfPresent(IPersonAttributes person) { IPersonAttributes rslt = person; final Map<String, List<Object>> overrides = overridesMap.get(person.getName()); if (overrides != null) { logger.debug( "Overriding the following collection of attributes for user '{}': {}", person.getName(), overrides); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); final Map<String, List<Object>> mergedAttributes = attributeMerger.mergeAttributes(mutableMap, overrides); rslt = new NamedPersonImpl(person.getName(), mergedAttributes); } return rslt; } }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes applyOverridesIfPresent(IPersonAttributes person) { IPersonAttributes rslt = person; final Map<String, List<Object>> overrides = overridesMap.get(person.getName()); if (overrides != null) { logger.debug( "Overriding the following collection of attributes for user '{}': {}", person.getName(), overrides); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); final Map<String, List<Object>> mergedAttributes = attributeMerger.mergeAttributes(mutableMap, overrides); rslt = new NamedPersonImpl(person.getName(), mergedAttributes); } return rslt; }  }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes applyOverridesIfPresent(IPersonAttributes person) { IPersonAttributes rslt = person; final Map<String, List<Object>> overrides = overridesMap.get(person.getName()); if (overrides != null) { logger.debug( "Overriding the following collection of attributes for user '{}': {}", person.getName(), overrides); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); final Map<String, List<Object>> mergedAttributes = attributeMerger.mergeAttributes(mutableMap, overrides); rslt = new NamedPersonImpl(person.getName(), mergedAttributes); } return rslt; }  IPersonAttributeDao getDelegatePersonAttributeDao(); @Required void setDelegatePersonAttributeDao(IPersonAttributeDao delegatePersonAttributeDao); @Autowired void setUsernameAttributeProvider(IUsernameAttributeProvider usernameAttributeProvider); Map<String, Map<String, List<Object>>> getAttributeOverridesMap(); void setAttributeOverridesMap(Map<String, Map<String, List<Object>>> overridesMap); void setUserAttributeOverride(String uid, Map<String, Object> attributes); void removeUserAttributeOverride(String uid); @Override IPersonAttributes getPerson(String uid); @Override Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
            Map<String, List<Object>> query); @Override Set<String> getPossibleUserAttributeNames(); @Override Set<String> getAvailableQueryAttributes(); }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes applyOverridesIfPresent(IPersonAttributes person) { IPersonAttributes rslt = person; final Map<String, List<Object>> overrides = overridesMap.get(person.getName()); if (overrides != null) { logger.debug( "Overriding the following collection of attributes for user '{}': {}", person.getName(), overrides); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); final Map<String, List<Object>> mergedAttributes = attributeMerger.mergeAttributes(mutableMap, overrides); rslt = new NamedPersonImpl(person.getName(), mergedAttributes); } return rslt; }  IPersonAttributeDao getDelegatePersonAttributeDao(); @Required void setDelegatePersonAttributeDao(IPersonAttributeDao delegatePersonAttributeDao); @Autowired void setUsernameAttributeProvider(IUsernameAttributeProvider usernameAttributeProvider); Map<String, Map<String, List<Object>>> getAttributeOverridesMap(); void setAttributeOverridesMap(Map<String, Map<String, List<Object>>> overridesMap); void setUserAttributeOverride(String uid, Map<String, Object> attributes); void removeUserAttributeOverride(String uid); @Override IPersonAttributes getPerson(String uid); @Override Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
            Map<String, List<Object>> query); @Override Set<String> getPossibleUserAttributeNames(); @Override Set<String> getAvailableQueryAttributes();  }