public static CommonProfile restoreOrBuildProfile ( final ProfileDefinition < ? extends CommonProfile > profileDefinition , final String typedId , final Map < String , Object > profileAttributes , final Map < String , Object > authenticationAttributes , final Object ... parameters ) { if ( CommonHelper . isBlank ( typedId ) ) { return null ; } logger . info ( "Building user profile based on typedId: {}" , typedId ) ; final CommonProfile profile ; if ( typedId . contains ( CommonProfile . SEPARATOR ) ) { final String className = CommonHelper . substringBefore ( typedId , CommonProfile . SEPARATOR ) ; try { profile = buildUserProfileByClassCompleteName ( className ) ; } catch ( final TechnicalException e ) { logger . error ( "Cannot build instance for class name: {}" , className , e ) ; return null ; } profile . addAttributes ( profileAttributes ) ; profile . addAuthenticationAttributes ( authenticationAttributes ) ; } else { profile = profileDefinition . newProfile ( parameters ) ; profileDefinition . convertAndAdd ( profile , profileAttributes , authenticationAttributes ) ; } profile . setId ( ProfileHelper . sanitizeIdentifier ( profile , typedId ) ) ; return profile ; }
Restore or build a profile .