James Moger
2014-02-28 131da2786c1bf275c07ba628af4254a40d1dc42f
src/main/java/com/gitblit/ConfigUserService.java
@@ -133,7 +133,7 @@
    * @return cookie value
    */
   @Override
   public String getCookie(UserModel model) {
   public synchronized String getCookie(UserModel model) {
      if (!StringUtils.isEmpty(model.cookie)) {
         return model.cookie;
      }
@@ -195,7 +195,7 @@
    * @return true if update is successful
    */
   @Override
   public boolean updateUserModel(UserModel model) {
   public synchronized boolean updateUserModel(UserModel model) {
      return updateUserModel(model.username, model);
   }
@@ -216,18 +216,22 @@
            // null check on "final" teams because JSON-sourced UserModel
            // can have a null teams object
            if (model.teams != null) {
               Set<TeamModel> userTeams = new HashSet<TeamModel>();
               for (TeamModel team : model.teams) {
                  TeamModel t = teams.get(team.name.toLowerCase());
                  if (t == null) {
                     // new team
                     team.addUser(model.username);
                     teams.put(team.name.toLowerCase(), team);
                  } else {
                     // do not clobber existing team definition
                     // maybe because this is a federated user
                     t.addUser(model.username);
                     t = team;
                     teams.put(team.name.toLowerCase(), t);
                  }
                  // do not clobber existing team definition
                  // maybe because this is a federated user
                  t.addUser(model.username);
                  userTeams.add(t);
               }
               // replace Team-Models in users by new ones.
               model.teams.clear();
               model.teams.addAll(userTeams);
               // check for implicit team removal
               if (originalUser != null) {
@@ -268,6 +272,9 @@
         }
         read();
         originalUser = users.remove(username.toLowerCase());
         if (originalUser != null) {
            cookies.remove(originalUser.cookie);
         }
         users.put(model.username.toLowerCase(), model);
         // null check on "final" teams because JSON-sourced UserModel
         // can have a null teams object
@@ -318,7 +325,7 @@
    * @return true if successful
    */
   @Override
   public boolean deleteUserModel(UserModel model) {
   public synchronized boolean deleteUserModel(UserModel model) {
      return deleteUser(model.username);
   }
@@ -365,7 +372,7 @@
    * @since 0.8.0
    */
   @Override
   public List<String> getAllTeamNames() {
   public synchronized List<String> getAllTeamNames() {
      read();
      List<String> list = new ArrayList<String>(teams.keySet());
      Collections.sort(list);
@@ -440,7 +447,7 @@
    * @since 0.8.0
    */
   @Override
   public boolean updateTeamModel(TeamModel model) {
   public synchronized boolean updateTeamModel(TeamModel model) {
      return updateTeamModel(model.name, model);
   }
@@ -452,7 +459,7 @@
    * @since 1.2.0
    */
   @Override
   public boolean updateTeamModels(Collection<TeamModel> models) {
   public synchronized boolean updateTeamModels(Collection<TeamModel> models) {
      try {
         read();
         for (TeamModel team : models) {
@@ -478,7 +485,7 @@
    * @since 0.8.0
    */
   @Override
   public boolean updateTeamModel(String teamname, TeamModel model) {
   public synchronized boolean updateTeamModel(String teamname, TeamModel model) {
      TeamModel original = null;
      try {
         read();
@@ -507,7 +514,7 @@
    * @since 0.8.0
    */
   @Override
   public boolean deleteTeamModel(TeamModel model) {
   public synchronized boolean deleteTeamModel(TeamModel model) {
      return deleteTeam(model.name);
   }
@@ -519,7 +526,7 @@
    * @since 0.8.0
    */
   @Override
   public boolean deleteTeam(String teamname) {
   public synchronized boolean deleteTeam(String teamname) {
      try {
         // Read realm file
         read();
@@ -538,7 +545,7 @@
    * @return list of all usernames
    */
   @Override
   public List<String> getAllUsernames() {
   public synchronized List<String> getAllUsernames() {
      read();
      List<String> list = new ArrayList<String>(users.keySet());
      Collections.sort(list);
@@ -859,7 +866,7 @@
               user.emailAddress = config.getString(USER, username, EMAILADDRESS);
               user.accountType = AccountType.fromString(config.getString(USER, username, ACCOUNTTYPE));
               if (Constants.EXTERNAL_ACCOUNT.equals(user.password) && user.accountType.isLocal()) {
                  user.accountType = null;
                  user.accountType = AccountType.EXTERNAL;
               }
               user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT);
               user.organization = config.getString(USER, username, ORGANIZATION);