| | |
| | | import java.util.TreeMap; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | import javax.inject.Inject; |
| | | |
| | | import org.eclipse.jgit.storage.file.FileBasedConfig; |
| | | import org.eclipse.jgit.util.FS; |
| | | import org.slf4j.Logger; |
| | |
| | | |
| | | private FileBasedConfig projectConfigs; |
| | | |
| | | @Inject |
| | | public ProjectManager( |
| | | IRuntimeManager runtimeManager, |
| | | IUserManager userManager, |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IManager setup() { |
| | | public ProjectManager start() { |
| | | // load and cache the project metadata |
| | | projectConfigs = new FileBasedConfig(runtimeManager.getFileOrFolder(Keys.web.projectsFile, "${baseFolder}/projects.conf"), FS.detect()); |
| | | getProjectConfigs(); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public IManager stop() { |
| | | public ProjectManager stop() { |
| | | return this; |
| | | } |
| | | |
| | |
| | | map.put("", configs.get("")); |
| | | |
| | | for (RepositoryModel model : repositoryManager.getRepositoryModels(user)) { |
| | | String rootPath = StringUtils.getRootPath(model.name).toLowerCase(); |
| | | if (!map.containsKey(rootPath)) { |
| | | String projectPath = StringUtils.getRootPath(model.name); |
| | | String projectKey = projectPath.toLowerCase(); |
| | | if (!map.containsKey(projectKey)) { |
| | | ProjectModel project; |
| | | if (configs.containsKey(rootPath)) { |
| | | if (configs.containsKey(projectKey)) { |
| | | // clone the project model because it's repository list will |
| | | // be tailored for the requesting user |
| | | project = DeepCopier.copy(configs.get(rootPath)); |
| | | project = DeepCopier.copy(configs.get(projectKey)); |
| | | } else { |
| | | project = new ProjectModel(rootPath); |
| | | project = new ProjectModel(projectPath); |
| | | } |
| | | map.put(rootPath, project); |
| | | map.put(projectKey, project); |
| | | } |
| | | map.get(rootPath).addRepository(model); |
| | | map.get(projectKey).addRepository(model); |
| | | } |
| | | |
| | | // sort projects, root project first |