Search in sources :

Example 31 with Group

use of org.opengrok.indexer.configuration.Group in project OpenGrok by OpenGrok.

the class PageConfigRequestedProjectsTest method setUp.

@BeforeEach
public void setUp() {
    oldProjects = env.getProjects();
    oldGroups = env.getGroups();
    oldPluginStack = env.getPluginStack();
    Set<Group> groups = new TreeSet<>();
    Map<String, Project> projects = new TreeMap<>();
    for (int i = 0; i < 10; i++) {
        Project project = new Project();
        project.setName("project-" + i);
        project.setPath("/project-" + i);
        project.setIndexed(true);
        projects.put("project-" + i, project);
    }
    Group group;
    group = new Group();
    group.setName("group-1-2-3");
    group.setPattern("project-(1|2|3)");
    groups.add(group);
    group = new Group();
    group.setName("group-7-8-9");
    group.setPattern("project-(7|8|9)");
    groups.add(group);
    env.setGroups(groups);
    env.setProjects(projects);
    env.setProjectsEnabled(true);
    env.setPluginStack(null);
    env.applyConfig(false, CommandTimeoutType.INDEXER);
}
Also used : Group(org.opengrok.indexer.configuration.Group) Project(org.opengrok.indexer.configuration.Project) TreeSet(java.util.TreeSet) TreeMap(java.util.TreeMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 32 with Group

use of org.opengrok.indexer.configuration.Group in project OpenGrok by OpenGrok.

the class ProjectsController method deleteProjectWorkHorse.

private void deleteProjectWorkHorse(String projectName, Project project) {
    // Delete index data associated with the project.
    deleteProjectDataWorkHorse(projectName, true);
    // Remove the project from its groups.
    for (Group group : project.getGroups()) {
        group.getRepositories().remove(project);
        group.getProjects().remove(project);
    }
    if (env.isHistoryEnabled()) {
        // Now remove the repositories associated with this project.
        List<RepositoryInfo> repos = env.getProjectRepositoriesMap().get(project);
        if (repos != null) {
            env.getRepositories().removeAll(repos);
        }
        env.getProjectRepositoriesMap().remove(project);
    }
    env.getProjects().remove(projectName, project);
    // Prevent the project to be included in new searches.
    env.refreshSearcherManagerMap();
}
Also used : Group(org.opengrok.indexer.configuration.Group) RepositoryInfo(org.opengrok.indexer.history.RepositoryInfo)

Example 33 with Group

use of org.opengrok.indexer.configuration.Group in project OpenGrok by OpenGrok.

the class ProjectHelper method populateGroups.

/**
 * Generates ungrouped projects and repositories.
 */
private void populateGroups() {
    groups.addAll(cfg.getEnv().getGroups());
    for (Project project : cfg.getEnv().getProjectList()) {
        // filterProjects() only adds groups which match project's name.
        Set<Group> copy = Group.matching(project, groups);
        // If no group matches the project, add it to not-grouped projects.
        if (copy.isEmpty()) {
            if (cfg.getEnv().getProjectRepositoriesMap().get(project) == null) {
                ungroupedProjects.add(project);
            } else {
                ungroupedRepositories.add(project);
            }
        }
    }
    // populate all grouped
    for (Group g : getGroups()) {
        allProjects.addAll(g.getProjects());
        allRepositories.addAll(g.getRepositories());
    }
}
Also used : Project(org.opengrok.indexer.configuration.Project) Group(org.opengrok.indexer.configuration.Group)

Aggregations

Group (org.opengrok.indexer.configuration.Group)33 Test (org.junit.jupiter.api.Test)19 Project (org.opengrok.indexer.configuration.Project)19 DummyHttpServletRequest (org.opengrok.indexer.web.DummyHttpServletRequest)7 User (opengrok.auth.plugin.entity.User)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TreeSet (java.util.TreeSet)3 Entity (jakarta.ws.rs.client.Entity)2 GenericType (jakarta.ws.rs.core.GenericType)2 Response (jakarta.ws.rs.core.Response)2 IOException (java.io.IOException)2 Files (java.nio.file.Files)2 Path (java.nio.file.Path)2 Paths (java.nio.file.Paths)2