Class ProfileFormFieldService

java.lang.Object
io.meeds.social.core.profileproperty.service.ProfileFormFieldService

@Service public class ProfileFormFieldService extends Object
Owns the rules of the profile attributes the account and registration forms write: which attributes a form lists, which values it accepts, and how they are saved in the user's profile.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ProfileFormFieldService(ProfileSettingStorage profileSettingStorage, org.exoplatform.social.core.storage.api.IdentityStorage identityStorage, org.exoplatform.social.core.manager.IdentityManager identityManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.exoplatform.social.core.identity.model.Profile
    getProfile(String username)
    Reads a user's profile through a lookup that creates no identity, so that a read made before a write, a dry run included, writes nothing.
    List<org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting>
    Reads the attributes a form lists from the store, never from a cache, in the settings' order: the settings whose flag for the form is on, keeping only those a form can write whatever their stored flags say.
    getStoredValues(List<org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting> settings, org.exoplatform.social.core.identity.model.Profile profile)
    Reads the values a profile holds for the attributes of a form, as validate(List, ProfileFormKind, boolean, Profile) reads a stored value.
    void
    save(String username, Map<String,Object> values, String modifier)
    Writes validated values in a user's profile, once, with the contact event, so that the group synchronization runs whatever this node's caches hold.
    validate(List<ProfilePropertyValue> values, ProfileFormKind kind, boolean complete, org.exoplatform.social.core.identity.model.Profile stored)
    Checks the values a form sends against the form's allow-list and the value rules, and builds them in the storage shape.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ProfileFormFieldService

      public ProfileFormFieldService(ProfileSettingStorage profileSettingStorage, org.exoplatform.social.core.storage.api.IdentityStorage identityStorage, org.exoplatform.social.core.manager.IdentityManager identityManager)
  • Method Details

    • getSettings

      public List<org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting> getSettings(ProfileFormKind kind)
      Reads the attributes a form lists from the store, never from a cache, in the settings' order: the settings whose flag for the form is on, keeping only those a form can write whatever their stored flags say.
      Parameters:
      kind - the form
      Returns:
      the form's allow-list
    • validate

      public Map<String,Object> validate(List<ProfilePropertyValue> values, ProfileFormKind kind, boolean complete, org.exoplatform.social.core.identity.model.Profile stored)
      Checks the values a form sends against the form's allow-list and the value rules, and builds them in the storage shape. Nothing is written.
      Parameters:
      values - the values sent
      kind - the form
      complete - true on creation, registration and onboarding, where every Required attribute of the form must be sent, or, given a stored profile, be held by it with a non-blank value
      stored - the user's profile on edition and onboarding, null on creation and registration: an attribute sent empty clears its value, and a dropdown value equal to a stored one is kept
      Returns:
      the attributes to write, by name: a text for a single-valued attribute, an ArrayList of maps holding the value under "value" for a multi-valued one
      Throws:
      ProfileFormFieldException - the first value refused, with its code and attribute name
    • save

      public void save(String username, Map<String,Object> values, String modifier) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Writes validated values in a user's profile, once, with the contact event, so that the group synchronization runs whatever this node's caches hold.
      Parameters:
      username - the user's login
      values - the attributes to write, as validate(List, ProfileFormKind, boolean, Profile) returns them
      modifier - the login of the user who writes
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the user has no identity, or a deleted one
    • getStoredValues

      public Map<String, List<String>> getStoredValues(List<org.exoplatform.social.core.profileproperty.model.ProfilePropertySetting> settings, org.exoplatform.social.core.identity.model.Profile profile)
      Reads the values a profile holds for the attributes of a form, as validate(List, ProfileFormKind, boolean, Profile) reads a stored value.
      Parameters:
      settings - the form's attributes
      profile - the user's profile, null when the user has no identity
      Returns:
      by attribute name, the non-empty values the profile holds for it, with no entry for an attribute it holds none for; an empty map for a null profile
    • getProfile

      public org.exoplatform.social.core.identity.model.Profile getProfile(String username) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Reads a user's profile through a lookup that creates no identity, so that a read made before a write, a dry run included, writes nothing.
      Parameters:
      username - the user's login
      Returns:
      the user's profile, a disabled user's included
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - when the user has no identity, or a deleted one