Search in sources :

Example 1 with CreateProject

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

the class ProjectApiImpl method create.

@Override
public ProjectApi create(ProjectInput in) throws RestApiException {
    try {
        if (name == null) {
            throw new ResourceConflictException("Project already exists");
        }
        if (in.name != null && !name.equals(in.name)) {
            throw new BadRequestException("name must match input.name");
        }
        CreateProject impl = createProjectFactory.create(name);
        permissionBackend.user(user).checkAny(GlobalPermission.fromAnnotation(impl.getClass()));
        impl.apply(TopLevelResource.INSTANCE, in);
        return projectApi.create(projects.parse(name));
    } catch (Exception e) {
        throw asRestApiException("Cannot create project: " + e.getMessage(), e);
    }
}
Also used : ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) CreateProject(com.google.gerrit.server.project.CreateProject) 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)

Aggregations

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 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)1 CreateProject (com.google.gerrit.server.project.CreateProject)1