@Override
    public CustomProfile extractUserProfile(User user) throws InvalidDefinitionException {
        // fetch custom attributes
        List<UserAttributes> userAttributes = user.getAttributes().stream()
                .filter(ua -> !ua.getIdentifier().startsWith("aac."))
                .collect(Collectors.toList());
        // fetch identities
        Collection<UserIdentity> identities = user.getIdentities();
        if (identities.isEmpty()) {
            return extract(userAttributes);
        }
        // TODO decide how to merge identities into a single profile
        // for now get first identity, should be last logged in
        UserIdentity id = identities.iterator().next();
        CustomProfile profile = extract(mergeAttributes(userAttributes, id.getAttributes()));
        return profile;
    }
@Override
    public CustomProfile extractUserProfile(User user) throws InvalidDefinitionException {
       
        List<UserAttributes> userAttributes = user.getAttributes().stream()
                .filter(ua -> !ua.getIdentifier().startsWith("aac."))
                .collect(Collectors.toList());
       
        Collection<UserIdentity> identities = user.getIdentities();
        if (identities.isEmpty()) {
            return extract(userAttributes);
        }
       
       
        UserIdentity id = identities.iterator().next();
        CustomProfile profile = extract(mergeAttributes(userAttributes, id.getAttributes()));
        return profile;
    }
@override public customprofile extractuserprofile(user user) throws invaliddefinitionexception { list<userattributes> userattributes = user.getattributes().stream() .filter(ua -> !ua.getidentifier().startswith("aac.")) .collect(collectors.tolist()); collection<useridentity> identities = user.getidentities(); if (identities.isempty()) { return extract(userattributes); } useridentity id = identities.iterator().next(); customprofile profile = extract(mergeattributes(userattributes, id.getattributes())); return profile; }