use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.
the class AuthorizationFrameworkTest method createUnallowedProject.
private Project createUnallowedProject() {
Project p = new Project();
p.setName("not_allowed" + "_" + "project" + Math.random());
return p;
}
use of org.opensolaris.opengrok.configuration.Project 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, List<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.setDirectoryName(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.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.
the class ProjectHelperTestBase method createProject.
protected static Project createProject(int index, int number, boolean grouped, boolean allowed, boolean repository, List<RepositoryInfo> rps, List<Project> prjs, Map<Project, List<RepositoryInfo>> map) {
Project p = new Project();
p.setName((allowed ? "allowed_" : "") + (grouped ? "grouped_" : "ungrouped_") + (repository ? "repository" : "project") + "_" + index + "_" + number);
prjs.add(p);
return p;
}
use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.
the class SearchEngine method searchMultiDatabase.
/**
* Perform search on multiple indexes in parallel.
* @param paging whether to use paging (if yes, first X pages will load
* faster)
* @param root list of projects to search
* @throws IOException
*/
private void searchMultiDatabase(List<Project> root, boolean paging) throws IOException {
SortedSet<String> projects = new TreeSet<>();
for (Project p : root) {
projects.add(p.getName());
}
// We use MultiReader even for single project. This should
// not matter given that MultiReader is just a cheap wrapper
// around set of IndexReader objects.
MultiReader searchables = RuntimeEnvironment.getInstance().getMultiReader(projects, searcherList);
searcher = new IndexSearcher(searchables);
collector = TopScoreDocCollector.create(hitsPerPage * cachePages);
searcher.search(query, collector);
totalHits = collector.getTotalHits();
if (!paging && totalHits > 0) {
collector = TopScoreDocCollector.create(totalHits);
searcher.search(query, collector);
}
hits = collector.topDocs().scoreDocs;
for (ScoreDoc hit : hits) {
int docId = hit.doc;
Document d = searcher.doc(docId);
docs.add(d);
}
}
use of org.opensolaris.opengrok.configuration.Project in project OpenGrok by OpenGrok.
the class SearchEngine method search.
/**
* Execute a search aware of current request, limited to specific project names.
*
* This filters out all projects which are not allowed for the current request.
*
* Before calling this function,
* you must set the appropriate search criteria with the set-functions. Note
* that this search will return the first cachePages of hitsPerPage, for
* more you need to call more.
*
* Call to search() must be eventually followed by call to destroy()
* so that IndexSearcher objects are properly freed.
*
* @return The number of hits
* @see ProjectHelper#getAllProjects()
*/
public int search(HttpServletRequest req, String... projectNames) {
ProjectHelper pHelper = PageConfig.get(req).getProjectHelper();
Set<Project> projects = pHelper.getAllProjects();
List<Project> filteredProjects = new ArrayList<Project>();
for (Project project : projects) {
for (String name : projectNames) {
if (project.getName().equalsIgnoreCase(name)) {
filteredProjects.add(project);
}
}
}
return search(filteredProjects, new File(RuntimeEnvironment.getInstance().getDataRootFile(), IndexDatabase.INDEX_DIR));
}
Aggregations