@ SuppressWarnings ( "unchecked" ) public String getUserEmail ( String userId ) { if ( userId == null ) { return null ; } // map userId to email // NOTE: this gets convoluted if they use OAuth logins because the email // field is in the service! Map < String , Object > user = getDocument ( "users" , userId ) ; String email = userId ; if ( user != null ) { ArrayList < Map < String , String > > emails = ( ArrayList < Map < String , String > > ) user . get ( "emails" ) ; if ( ( emails != null ) && ( emails . size ( ) > 0 ) ) { // get first email address Map < String , String > emailFields = emails . get ( 0 ) ; email = emailFields . get ( "address" ) ; } } return email ; }
Gets email address for user