use of com.google.gerrit.server.git.RepositoryCaseMismatchException in project gerrit by GerritCodeReview.
the class CreateProject method createProject.
private Project createProject(CreateProjectArgs args) throws BadRequestException, ResourceConflictException, IOException, ConfigInvalidException {
final Project.NameKey nameKey = args.getProject();
try {
final String head = args.permissionsOnly ? RefNames.REFS_CONFIG : args.branch.get(0);
try (Repository repo = repoManager.openRepository(nameKey)) {
if (repo.getObjectDatabase().exists()) {
throw new ResourceConflictException("project \"" + nameKey + "\" exists");
}
} catch (RepositoryNotFoundException e) {
// It does not exist, safe to ignore.
}
try (Repository repo = repoManager.createRepository(nameKey)) {
RefUpdate u = repo.updateRef(Constants.HEAD);
u.disableRefLog();
u.link(head);
createProjectConfig(args);
if (!args.permissionsOnly && args.createEmptyCommit) {
createEmptyCommits(repo, nameKey, args.branch);
}
fire(nameKey, head);
return projectCache.get(nameKey).getProject();
}
} catch (RepositoryCaseMismatchException e) {
throw new ResourceConflictException("Cannot create " + nameKey.get() + " because the name is already occupied by another project." + " The other project has the same name, only spelled in a" + " different case.");
} catch (RepositoryNotFoundException badName) {
throw new BadRequestException("invalid project name: " + nameKey);
} catch (ConfigInvalidException e) {
String msg = "Cannot create " + nameKey;
log.error(msg, e);
throw e;
}
}
Aggregations