use of org.opengrok.indexer.history.RepositoryInfo in project OpenGrok by OpenGrok.
the class ProjectHelperTestBase method createRepository.
protected static Project createRepository(int index, int number, int cnt, boolean grouped, boolean allowed, List<RepositoryInfo> rps, Map<String, Project> prjs, Map<Project, List<RepositoryInfo>> map) {
Project p = createProject(index, number, grouped, allowed, true, rps, prjs, map);
for (int i = 0; i < cnt; i++) {
RepositoryInfo info = new RepoRepository();
info.setParent(p.getName() + "_" + i);
info.setDirectoryNameRelative(p.getPath());
rps.add(info);
List<RepositoryInfo> infos = map.get(p);
if (infos == null) {
infos = new ArrayList<>();
}
infos.add(info);
map.put(p, infos);
}
return p;
}
use of org.opengrok.indexer.history.RepositoryInfo in project OpenGrok by OpenGrok.
the class ProjectsController method set.
@PUT
@Path("/{project}/property/{field}")
public void set(@PathParam("project") String projectName, @PathParam("field") String field, final String value) throws IOException {
// Avoid classification as a taint bug.
projectName = Laundromat.launderInput(projectName);
field = Laundromat.launderInput(field);
Project project = env.getProjects().get(projectName);
if (project != null) {
// Set the property.
ClassUtil.setFieldValue(project, field, value);
// Refresh field values for project's repositories for this project as well.
List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project);
if (riList != null) {
for (RepositoryInfo ri : riList) {
// Set the property if there is one.
if (ClassUtil.hasField(ri, field)) {
ClassUtil.setFieldValue(ri, field, value);
}
}
}
} else {
LOGGER.log(Level.WARNING, "cannot find project {0} to set a property", projectName);
}
}
use of org.opengrok.indexer.history.RepositoryInfo 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();
}
use of org.opengrok.indexer.history.RepositoryInfo in project OpenGrok by OpenGrok.
the class ProjectsController method markIndexed.
@PUT
@Path("/{project}/indexed")
@Consumes(MediaType.TEXT_PLAIN)
public Response markIndexed(@Context HttpServletRequest request, @PathParam("project") String projectNameParam) {
// Avoid classification as a taint bug.
final String projectName = Laundromat.launderInput(projectNameParam);
Project project = env.getProjects().get(projectName);
if (project == null) {
LOGGER.log(Level.WARNING, "cannot find project {0} to mark as indexed", projectName);
throw new NotFoundException(String.format("project '%s' does not exist", projectName));
}
project.setIndexed(true);
return ApiTaskManager.getInstance().submitApiTask(PROJECTS_PATH, new ApiTask(request.getRequestURI(), () -> {
// Refresh current version of the project's repositories.
List<RepositoryInfo> riList = env.getProjectRepositoriesMap().get(project);
if (riList != null) {
for (RepositoryInfo ri : riList) {
Repository repo = getRepository(ri, CommandTimeoutType.RESTFUL);
if (repo != null && repo.getCurrentVersion() != null && repo.getCurrentVersion().length() > 0) {
// getRepository() always creates fresh instance
// of the Repository object so there is no need
// to call setCurrentVersion() on it.
ri.setCurrentVersion(repo.determineCurrentVersion());
}
}
}
CompletableFuture.runAsync(() -> suggester.rebuild(projectName));
// In case this project has just been incrementally indexed,
// its IndexSearcher needs a poke.
env.maybeRefreshIndexSearchers(Collections.singleton(projectName));
env.refreshDateForLastIndexRun();
return null;
}));
}
use of org.opengrok.indexer.history.RepositoryInfo in project OpenGrok by OpenGrok.
the class ProjectsController method getRepositoriesType.
@GET
@Path("/{project}/repositories/type")
@Produces(MediaType.APPLICATION_JSON)
public Set<String> getRepositoriesType(@PathParam("project") String projectName) {
// Avoid classification as a taint bug.
projectName = Laundromat.launderInput(projectName);
Project project = env.getProjects().get(projectName);
if (project != null) {
List<RepositoryInfo> infos = env.getProjectRepositoriesMap().get(project);
if (infos != null) {
return infos.stream().map(RepositoryInfo::getType).collect(Collectors.toSet());
}
}
return Collections.emptySet();
}
Aggregations