Search in sources :

Example 1 with ListChildProjects

use of com.google.gerrit.server.project.ListChildProjects in project gerrit by GerritCodeReview.

the class ProjectApiImpl method children.

@Override
public List<ProjectInfo> children(boolean recursive) throws RestApiException {
    ListChildProjects list = children.list();
    list.setRecursive(recursive);
    try {
        return list.apply(checkExists());
    } catch (Exception e) {
        throw asRestApiException("Cannot list children", e);
    }
}
Also used : ListChildProjects(com.google.gerrit.server.project.ListChildProjects) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException)

Example 2 with ListChildProjects

use of com.google.gerrit.server.project.ListChildProjects in project gerrit by GerritCodeReview.

the class ParentProjectPredicate method predicates.

protected static List<Predicate<ChangeData>> predicates(ProjectCache projectCache, Provider<ListChildProjects> listChildProjects, Provider<CurrentUser> self, String value) {
    ProjectState projectState = projectCache.get(new Project.NameKey(value));
    if (projectState == null) {
        return Collections.emptyList();
    }
    List<Predicate<ChangeData>> r = new ArrayList<>();
    r.add(new ProjectPredicate(projectState.getProject().getName()));
    try {
        ProjectResource proj = new ProjectResource(projectState.controlFor(self.get()));
        ListChildProjects children = listChildProjects.get();
        children.setRecursive(true);
        for (ProjectInfo p : children.apply(proj)) {
            r.add(new ProjectPredicate(p.name));
        }
    } catch (PermissionBackendException e) {
        log.warn("cannot check permissions to expand child projects", e);
    }
    return r;
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ListChildProjects(com.google.gerrit.server.project.ListChildProjects) ArrayList(java.util.ArrayList) ProjectInfo(com.google.gerrit.extensions.common.ProjectInfo) ProjectState(com.google.gerrit.server.project.ProjectState) ProjectResource(com.google.gerrit.server.project.ProjectResource) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) OrPredicate(com.google.gerrit.server.query.OrPredicate) Predicate(com.google.gerrit.server.query.Predicate)

Aggregations

ListChildProjects (com.google.gerrit.server.project.ListChildProjects)2 ProjectInfo (com.google.gerrit.extensions.common.ProjectInfo)1 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)1 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)1 Project (com.google.gerrit.reviewdb.client.Project)1 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)1 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)1 ProjectResource (com.google.gerrit.server.project.ProjectResource)1 ProjectState (com.google.gerrit.server.project.ProjectState)1 OrPredicate (com.google.gerrit.server.query.OrPredicate)1 Predicate (com.google.gerrit.server.query.Predicate)1 ArrayList (java.util.ArrayList)1