Search in sources :

Example 16 with ProjectResource

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

the class ChildProjectsCollection method parse.

@Override
public ChildProjectResource parse(ProjectResource parent, IdString id) throws RestApiException, IOException, PermissionBackendException {
    parent.getProjectState().checkStatePermitsRead();
    ProjectResource p = projectsCollection.parse(TopLevelResource.INSTANCE, id);
    for (ProjectState pp : p.getProjectState().parents()) {
        if (parent.getNameKey().equals(pp.getProject().getNameKey())) {
            return new ChildProjectResource(parent, p.getProjectState());
        }
    }
    throw new ResourceNotFoundException(id);
}
Also used : ChildProjectResource(com.google.gerrit.server.project.ChildProjectResource) ChildProjectResource(com.google.gerrit.server.project.ChildProjectResource) ProjectResource(com.google.gerrit.server.project.ProjectResource) ProjectState(com.google.gerrit.server.project.ProjectState) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException)

Example 17 with ProjectResource

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

the class BanCommitCommand method run.

@Override
protected void run() throws Failure {
    enableGracefulStop();
    try {
        BanCommitInput input = BanCommitInput.fromCommits(Lists.transform(commitsToBan, ObjectId::getName));
        input.reason = reason;
        BanResultInfo r = banCommit.apply(new ProjectResource(projectState, user), input).value();
        printCommits(r.newlyBanned, "The following commits were banned");
        printCommits(r.alreadyBanned, "The following commits were already banned");
        printCommits(r.ignored, "The following ids do not represent commits and were ignored");
    } catch (Exception e) {
        throw die(e);
    }
}
Also used : BanCommitInput(com.google.gerrit.extensions.api.projects.BanCommitInput) BanResultInfo(com.google.gerrit.server.restapi.project.BanCommit.BanResultInfo) ProjectResource(com.google.gerrit.server.project.ProjectResource)

Aggregations

ProjectResource (com.google.gerrit.server.project.ProjectResource)17 ProjectState (com.google.gerrit.server.project.ProjectState)7 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)5 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)5 Project (com.google.gerrit.entities.Project)4 IdString (com.google.gerrit.extensions.restapi.IdString)4 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)4 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)4 RestApiException (com.google.gerrit.extensions.restapi.RestApiException)4 ArrayList (java.util.ArrayList)4 ProjectInfo (com.google.gerrit.extensions.common.ProjectInfo)3 UnprocessableEntityException (com.google.gerrit.extensions.restapi.UnprocessableEntityException)3 Project (com.google.gerrit.reviewdb.client.Project)3 AuthException (com.google.gerrit.extensions.restapi.AuthException)2 MethodNotAllowedException (com.google.gerrit.extensions.restapi.MethodNotAllowedException)2 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)2 RepositoryNotFoundException (org.eclipse.jgit.errors.RepositoryNotFoundException)2 ImmutableList (com.google.common.collect.ImmutableList)1 Capable (com.google.gerrit.common.data.Capable)1 BooleanProjectConfig (com.google.gerrit.entities.BooleanProjectConfig)1