James Moger
2014-05-16 1b34b05f5b8d2d0fd51819b286e22d7ddd27cb27
src/main/java/com/gitblit/ConfigUserService.java
@@ -24,6 +24,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -36,6 +37,7 @@
import com.gitblit.Constants.AccessPermission;
import com.gitblit.Constants.AccountType;
import com.gitblit.Constants.Transport;
import com.gitblit.manager.IRuntimeManager;
import com.gitblit.models.TeamModel;
import com.gitblit.models.UserModel;
@@ -96,7 +98,13 @@
   private static final String LOCALE = "locale";
   private static final String EMAILONMYTICKETCHANGES = "emailMeOnMyTicketChanges";
   private static final String TRANSPORT = "transport";
   private static final String ACCOUNTTYPE = "accountType";
   private static final String DISABLED = "disabled";
   private final File realmFile;
@@ -701,9 +709,25 @@
         if (!StringUtils.isEmpty(model.countryCode)) {
            config.setString(USER, model.username, COUNTRYCODE, model.countryCode);
         }
         if (model.disabled) {
            config.setBoolean(USER, model.username, DISABLED, true);
         }
         if (model.getPreferences() != null) {
            if (!StringUtils.isEmpty(model.getPreferences().locale)) {
               config.setString(USER, model.username, LOCALE, model.getPreferences().locale);
            Locale locale = model.getPreferences().getLocale();
            if (locale != null) {
               String val;
               if (StringUtils.isEmpty(locale.getCountry())) {
                  val = locale.getLanguage();
               } else {
                  val = locale.getLanguage() + "_" + locale.getCountry();
               }
               config.setString(USER, model.username, LOCALE, val);
            }
            config.setBoolean(USER, model.username, EMAILONMYTICKETCHANGES, model.getPreferences().isEmailMeOnMyTicketChanges());
            if (model.getPreferences().getTransport() != null) {
               config.setString(USER, model.username, TRANSPORT, model.getPreferences().getTransport().name());
            }
         }
@@ -868,17 +892,22 @@
               if (Constants.EXTERNAL_ACCOUNT.equals(user.password) && user.accountType.isLocal()) {
                  user.accountType = AccountType.EXTERNAL;
               }
               user.disabled = config.getBoolean(USER, username, DISABLED, false);
               user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT);
               user.organization = config.getString(USER, username, ORGANIZATION);
               user.locality = config.getString(USER, username, LOCALITY);
               user.stateProvince = config.getString(USER, username, STATEPROVINCE);
               user.countryCode = config.getString(USER, username, COUNTRYCODE);
               user.cookie = config.getString(USER, username, COOKIE);
               user.getPreferences().locale = config.getString(USER, username, LOCALE);
               if (StringUtils.isEmpty(user.cookie) && !StringUtils.isEmpty(user.password)) {
                  user.cookie = StringUtils.getSHA1(user.username + user.password);
               }
               // preferences
               user.getPreferences().setLocale(config.getString(USER, username, LOCALE));
               user.getPreferences().setEmailMeOnMyTicketChanges(config.getBoolean(USER, username, EMAILONMYTICKETCHANGES, true));
               user.getPreferences().setTransport(Transport.fromString(config.getString(USER, username, TRANSPORT)));
               // user roles
               Set<String> roles = new HashSet<String>(Arrays.asList(config.getStringList(
                     USER, username, ROLE)));