1 package com.atlassian.sal.api.usersettings;
2
3 import com.google.common.base.Function;
4
5 /**
6 * Service for getting and updating immutable UserSettings objects stored against a user name
7 *
8 * @since 2.9
9 */
10 public interface UserSettingsService
11 {
12 /**
13 * Gets the UserSettings for the user with name userName
14 * @param userName name of the user whose user settings are to be retrieved
15 * @return a UserSettings for the user with name userName,
16 * @throws IllegalArgumentException if no user could be found with that name
17 */
18 UserSettings getUserSettings(String userName);
19
20 /**
21 * Updates the UserSettings stored for this user with name UserName. Implementations of this interface will ensure
22 * that updateFunctions provided to this method are called in a threadsafe manner.
23 *
24 * Consumers can throw RuntimeExceptions within updateFunction to control flow when the input to updateFunction
25 * is unexpected. As such, implementers must either rethrow caught RuntimeExceptions, or not catch them in the first place.
26 *
27 * @param userName name of the user whose UserSettings are to be updated. If userName does not match a known user,
28 * updateFunction will not be called.
29 * @param updateFunction function to update a user's UserSettings. The parameter to updateFunction is a
30 * UserSettingsBuilder whose contents match the UserSettings for the provided user. The
31 * return value of updateFunction will be stored against the specified user.
32 *
33 * @throws IllegalArgumentException if no user could be found with that name
34 */
35 void updateUserSettings(String userName, Function<UserSettingsBuilder, UserSettings> updateFunction);
36
37 }