Class UserInfoBase

  • Direct Known Subclasses:
    BasicUserInfo

    public abstract class UserInfoBase
    extends java.lang.Object
    The base of user information in the database. The implementing subclass in the server extends from this class.
    Author:
    Christopher Mindus
    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      longcreated
      The 'created' time in milliseconds since the epoch.
      java.lang.Stringemail
      The 'email', never null (max 254 chars).
      longid
      The unique ID.
      java.util.List<java.lang.String>langCodes
      The unpacked 'lang_codes' as language codes the user wishes to use.
      static intMAXIMUM_USER_NAME_LENGTH
      The maximum length of the user name.
      java.lang.StringuserName
      The 'user_name', never null (max 254 chars).
      java.lang.StringuserNameLower
      The 'user_name_lower', lower case using Locale.ENGLISH of 'user_name', never null (max 254 chars).
    • Constructor Summary

      Constructors 
      ModifierConstructorDescription
      protectedUserInfoBase​(long id, java.lang.String userName, java.lang.String userNameLower, java.lang.String email, java.lang.String langCode, long created)
      Constructor for the user info base.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and TypeMethodDescription
      abstract java.lang.StringcanChangePassword()
      Checks if the user is allowed to change his password.
      booleanequals​(java.lang.Object o)
      Checks for equality.
      abstract java.util.Map<java.lang.String,​java.lang.String>getDetails()
      Gets the cached and current user details.
      abstract java.util.Map<java.lang.String,​java.lang.String>getDetails​(boolean reload)
      Gets the (cached and current) user details.
      abstract java.util.Map<java.lang.String,​java.lang.String>getDetails​(java.sql.Connection conn, boolean reload)
      Gets the user details.
      abstract java.lang.StringgetDisabledReason()
      Gets the 'disabled' reason string, null for user not disabled.
      abstract intgetFailCount()
      Gets the 'fail_count' value, zero for never.
      abstract longgetLastFail()
      Gets the 'last_fail' time in milliseconds since the epoch, 0 for never.
      abstract longgetLastLogin()
      Gets the 'last_login' time in milliseconds since the epoch, 0 for never.
      abstract booleanmustChangePassword()
      Returns if the password must be changed upon next login.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAXIMUM_USER_NAME_LENGTH

        public static final int MAXIMUM_USER_NAME_LENGTH
        The maximum length of the user name.
        See Also:
        Constant Field Values
      • id

        public final long id
        The unique ID.
      • userName

        public final java.lang.String userName
        The 'user_name', never null (max 254 chars).
      • userNameLower

        public final java.lang.String userNameLower
        The 'user_name_lower', lower case using Locale.ENGLISH of 'user_name', never null (max 254 chars).
      • email

        public final java.lang.String email
        The 'email', never null (max 254 chars).
      • langCodes

        public final java.util.List<java.lang.String> langCodes
        The unpacked 'lang_codes' as language codes the user wishes to use. The value is null if there are no language codes. The list is unmodifiable.
      • created

        public final long created
        The 'created' time in milliseconds since the epoch.
    • Constructor Detail

      • UserInfoBase

        protected UserInfoBase​(long id,
                               java.lang.String userName,
                               java.lang.String userNameLower,
                               java.lang.String email,
                               java.lang.String langCode,
                               long created)
        Constructor for the user info base.
        Parameters:
        id - The unique user ID.
        userName - The user name, never null.
        userNameLower - The user name in lower case, never null.
        email - The email, never null.
        langCode - The language codes, comma separated, null for none.
        created - The creation date (milliseconds since the epoch).
    • Method Detail

      • equals

        public final boolean equals​(java.lang.Object o)
        Checks for equality. Checks only if two user ID's are equal.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        o - The object to compare with.
        Returns:
        When user ID equals, false otherwise.
      • mustChangePassword

        public abstract boolean mustChangePassword()
        Returns if the password must be changed upon next login.
        Returns:
        Flag to change the password.
      • canChangePassword

        public abstract java.lang.String canChangePassword()
        Checks if the user is allowed to change his password.
        Returns:
        null if allowed and user can change his password, otherwise an English text for the reason of the password being fixed and that it can never be changed.
      • getLastLogin

        public abstract long getLastLogin()
        Gets the 'last_login' time in milliseconds since the epoch, 0 for never.
      • getLastFail

        public abstract long getLastFail()
        Gets the 'last_fail' time in milliseconds since the epoch, 0 for never.
      • getFailCount

        public abstract int getFailCount()
        Gets the 'fail_count' value, zero for never.
      • getDisabledReason

        public abstract java.lang.String getDisabledReason()
        Gets the 'disabled' reason string, null for user not disabled.
      • getDetails

        public abstract java.util.Map<java.lang.String,​java.lang.String> getDetails()
        Gets the cached and current user details. Details are e.g. fax number, profile picture.
        Returns:
        A new read-only copy of the details with name as key and the value for it.
      • getDetails

        public abstract java.util.Map<java.lang.String,​java.lang.String> getDetails​(boolean reload)
                                                                                   throws java.sql.SQLException
        Gets the (cached and current) user details. Details are e.g. fax number, profile picture.

        Note: If you have a JDBC connection, use getDetails(Connection, boolean) instead for efficiency.

        Parameters:
        reload - Reload flag from database.
        Returns:
        If reload is false, a cached read-only map with the details name as key and the value for it, otherwise a fresh copy of the details from the database.
        Throws:
        java.sql.SQLException - For SQL errors.
      • getDetails

        public abstract java.util.Map<java.lang.String,​java.lang.String> getDetails​(java.sql.Connection conn,
                                                                                          boolean reload)
                                                                                   throws java.sql.SQLException
        Gets the user details. Details are e.g. fax number, profile picture. If not previously loaded, the "reload" flag is ignored and the details are loaded.
        Parameters:
        conn - The connection, null for cached values only.
        reload - Reload flag, i.e. instructs a full reload of all details from the database.
        Returns:
        A cached read-only map with the details name as key and the value for it.
        Throws:
        java.sql.SQLException - For SQL errors.