Search in sources :

Example 1 with CreateRepositoryResponse

use of de.catma.repository.git.CreateRepositoryResponse in project catma by forTEXT.

the class GitlabManagerRestricted method createRepository.

@Override
public CreateRepositoryResponse createRepository(String name, String path, String groupPath) throws IOException {
    GroupApi groupApi = restrictedGitLabApi.getGroupApi();
    ProjectApi projectApi = restrictedGitLabApi.getProjectApi();
    try {
        Group group = groupApi.getGroup(groupPath);
        Namespace namespace = new Namespace();
        namespace.setId(group.getId());
        Project project = new Project();
        project.setName(name);
        project.setNamespace(namespace);
        if (StringUtils.isNotEmpty(path)) {
            project.setPath(path);
        }
        project = projectApi.createProject(project);
        return new CreateRepositoryResponse(groupPath, project.getId(), GitlabUtils.rewriteGitLabServerUrl(project.getHttpUrlToRepo()));
    } catch (GitLabApiException e) {
        throw new IOException("Failed to create remote Git repository", e);
    }
}
Also used : Group(org.gitlab4j.api.models.Group) Project(org.gitlab4j.api.models.Project) GroupApi(org.gitlab4j.api.GroupApi) ProjectApi(org.gitlab4j.api.ProjectApi) CreateRepositoryResponse(de.catma.repository.git.CreateRepositoryResponse) GitLabApiException(org.gitlab4j.api.GitLabApiException) IOException(java.io.IOException) Namespace(org.gitlab4j.api.models.Namespace)

Aggregations

CreateRepositoryResponse (de.catma.repository.git.CreateRepositoryResponse)1 IOException (java.io.IOException)1 GitLabApiException (org.gitlab4j.api.GitLabApiException)1 GroupApi (org.gitlab4j.api.GroupApi)1 ProjectApi (org.gitlab4j.api.ProjectApi)1 Group (org.gitlab4j.api.models.Group)1 Namespace (org.gitlab4j.api.models.Namespace)1 Project (org.gitlab4j.api.models.Project)1