Package org.openxava.util
Class Users
- java.lang.Object
-
- org.openxava.util.Users
-
public class Users extends java.lang.ObjectUtilities to work with users.- Author:
- Javier Paniza
-
-
Constructor Summary
Constructors Constructor Description Users()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.prefs.PreferencesgetAdminPreferences()Preferences of the admin user.static java.lang.StringgetCurrent()The user name associated to the current thread.static java.lang.StringgetCurrentIP()static java.util.prefs.PreferencesgetCurrentPreferences()Preferences of the user associated to the current thread.static UserInfogetCurrentUserInfo()Info about the current logged user.static java.util.prefs.PreferencesgetSharedPreferences()Preferences of the shared user.static voidsetCurrent(java.lang.String userName)Associated an user to the current thread.static voidsetCurrent(javax.servlet.http.HttpServletRequest request)Associated the user of the request to the current thread.static voidsetCurrentUserInfo(UserInfo userInfo)Associated the UserInfo object to the current thread.
-
-
-
Field Detail
-
ADMIN_OX
public static final java.lang.String ADMIN_OX
- See Also:
- Constant Field Values
-
SHARED_OX
public static final java.lang.String SHARED_OX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCurrent
public static java.lang.String getCurrent()
The user name associated to the current thread.- Returns:
nullif no user logged.
-
getCurrentIP
public static java.lang.String getCurrentIP()
- Since:
- 6.1
-
getCurrentPreferences
public static java.util.prefs.Preferences getCurrentPreferences() throws java.util.prefs.BackingStoreExceptionPreferences of the user associated to the current thread.You can use this preference for read and update user preferences, in this way:
// Obtain preferences for the current user and node (an arbitrary category of your choice). Preferences preferences = Users.getCurrentPreferences().node("mynode"); // Read a property value boolean rowsHidden = preferences.getBoolean(ROWS_HIDDEN, false); // Modify and save a property preferences.putBoolean(ROWS_HIDDEN, rowsHidden); preferences.flush();Remember, you must call flush() always in order to make persistent the changes in preferences.- Returns:
- The preferences object associated to the current user.
- Throws:
java.util.prefs.BackingStoreException- Some problem on load preferences.
-
getAdminPreferences
public static java.util.prefs.Preferences getAdminPreferences() throws java.util.prefs.BackingStoreExceptionPreferences of the admin user.- Returns:
- The preferences object associated to the admin user.
- Throws:
java.util.prefs.BackingStoreException- Some problem on load preferences.
-
getSharedPreferences
public static java.util.prefs.Preferences getSharedPreferences() throws java.util.prefs.BackingStoreExceptionPreferences of the shared user.- Returns:
- The preferences object associated to the shared user.
- Throws:
java.util.prefs.BackingStoreException- Some problem on load preferences.
-
getCurrentUserInfo
public static UserInfo getCurrentUserInfo()
Info about the current logged user.- Returns:
- Not null. If not info available it returns a UserInfo object with no info.
-
setCurrent
public static void setCurrent(java.lang.String userName)
Associated an user to the current thread.
-
setCurrentUserInfo
public static void setCurrentUserInfo(UserInfo userInfo)
Associated the UserInfo object to the current thread.
-
setCurrent
public static void setCurrent(javax.servlet.http.HttpServletRequest request)
Associated the user of the request to the current thread.
-
-