// Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
//   private static final int RESULTS_PER_REQUEST = 25;
//   private final UserService userService;
// 
//   public UserUtils(UserService userService) {
//     this.userService = userService;
//   }
// 
//   public List<User> dereferenceUsers(Iterable<String> users) {
//     List<User> list = newArrayList();
//     for(String u : users) {
//       Optional<User> user = getUserByName(u);
//       if(user.isPresent()) {
//         list.add(user.get());
//       }
//     }
//     return list;
//   }
// 
//   public Optional<User> getUserByName(String username) {
//     ApplicationUser user = userService.getUserByName(username);
//     return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
//   }
// 
//   public String getUserDisplayNameByName(String username) {
// 	    ApplicationUser user = userService.getUserByName(username);  
// 	    return user.getDisplayName() == null ? username : user.getDisplayName();
//   }
//   
//   public ApplicationUser getApplicationUserByName(String username) {
//     return userService.getUserByName(username);
//   }
// 
//   public List<String> dereferenceGroups(List<String> groups) {
//     List<String> users = newArrayList();
//     for(String group : groups) {
//       List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
//       for(int i = 1; results.size() > 0; i++) {
//         users.addAll(results.stream()
//             .map(ApplicationUser::getSlug)
//             .collect(Collectors.toList()));
//         results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
//       }
//     }
//     return users;
//   }
// 
// 
// }


import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionService;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.project.ProjectService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.RepositoryService;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.google.common.collect.ImmutableMap;
import com.monitorjbl.plugins.UserUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;
package com.monitorjbl.plugins.config;



public class ConfigServlet extends HttpServlet {
  public static final String SERVLET_PATH = "/plugins/servlet/pr-harmony/";
  private static final Logger logger = LoggerFactory.getLogger(ConfigServlet.class);

  private final UserManager userManager;
// Path: src/main/java/com/monitorjbl/plugins/UserUtils.java
// public class UserUtils {
//   private static final int RESULTS_PER_REQUEST = 25;
//   private final UserService userService;
// 
//   public UserUtils(UserService userService) {
//     this.userService = userService;
//   }
// 
//   public List<User> dereferenceUsers(Iterable<String> users) {
//     List<User> list = newArrayList();
//     for(String u : users) {
//       Optional<User> user = getUserByName(u);
//       if(user.isPresent()) {
//         list.add(user.get());
//       }
//     }
//     return list;
//   }
// 
//   public Optional<User> getUserByName(String username) {
//     ApplicationUser user = userService.getUserByName(username);
//     return user == null ? Optional.empty() : Optional.of(new User(user.getName(), user.getDisplayName()));
//   }
// 
//   public String getUserDisplayNameByName(String username) {
// 	    ApplicationUser user = userService.getUserByName(username);  
// 	    return user.getDisplayName() == null ? username : user.getDisplayName();
//   }
//   
//   public ApplicationUser getApplicationUserByName(String username) {
//     return userService.getUserByName(username);
//   }
// 
//   public List<String> dereferenceGroups(List<String> groups) {
//     List<String> users = newArrayList();
//     for(String group : groups) {
//       List<ApplicationUser> results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(0, RESULTS_PER_REQUEST)).getValues());
//       for(int i = 1; results.size() > 0; i++) {
//         users.addAll(results.stream()
//             .map(ApplicationUser::getSlug)
//             .collect(Collectors.toList()));
//         results = newArrayList(userService.findUsersByGroup(group, new PageRequestImpl(i * RESULTS_PER_REQUEST, RESULTS_PER_REQUEST)).getValues());
//       }
//     }
//     return users;
//   }
// 
// 
// }


// Path: src/main/java/com/monitorjbl/plugins/config/ConfigServlet.java
import com.atlassian.bitbucket.permission.Permission;
import com.atlassian.bitbucket.permission.PermissionService;
import com.atlassian.bitbucket.project.Project;
import com.atlassian.bitbucket.project.ProjectService;
import com.atlassian.bitbucket.repository.Repository;
import com.atlassian.bitbucket.repository.RepositoryService;
import com.atlassian.bitbucket.user.ApplicationUser;
import com.atlassian.sal.api.auth.LoginUriProvider;
import com.atlassian.sal.api.user.UserManager;
import com.atlassian.sal.api.user.UserProfile;
import com.atlassian.templaterenderer.TemplateRenderer;
import com.google.common.collect.ImmutableMap;
import com.monitorjbl.plugins.UserUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URI;

package com.monitorjbl.plugins.config;



public class ConfigServlet extends HttpServlet {
  public static final String SERVLET_PATH = "/plugins/servlet/pr-harmony/";
  private static final Logger logger = LoggerFactory.getLogger(ConfigServlet.class);

  private final UserManager userManager;
  private final UserUtils userUtils;