use of org.gitlab4j.api.models.ProjectAccess in project legend-sdlc by finos.
the class GitLabProjectApi method getUserAccess.
private AccessLevel getUserAccess(org.gitlab4j.api.models.Project gitLabProject) {
Permissions permissions = gitLabProject.getPermissions();
if (permissions != null) {
ProjectAccess projectAccess = permissions.getProjectAccess();
AccessLevel projectAccessLevel = (projectAccess == null) ? null : projectAccess.getAccessLevel();
if (projectAccessLevel != null) {
return projectAccessLevel;
}
ProjectAccess groupAccess = permissions.getGroupAccess();
return (groupAccess == null) ? null : groupAccess.getAccessLevel();
}
return null;
}
use of org.gitlab4j.api.models.ProjectAccess in project legend-sdlc by finos.
the class GitLabProjectApi method getCurrentUserAccessRole.
@Override
public AccessRole getCurrentUserAccessRole(String id) {
LegendSDLCServerException.validateNonNull(id, "id may not be null");
try {
GitLabProjectId projectId = parseProjectId(id);
org.gitlab4j.api.models.Project gitLabProject = withRetries(() -> getGitLabApi(projectId.getGitLabMode()).getProjectApi().getProject(projectId.getGitLabId()));
if (!isLegendSDLCProject(gitLabProject)) {
throw new LegendSDLCServerException("Failed to get project " + id);
}
Permissions permissions = gitLabProject.getPermissions();
if (permissions != null) {
ProjectAccess projectAccess = permissions.getProjectAccess();
AccessLevel projectAccessLevel = (projectAccess == null) ? null : projectAccess.getAccessLevel();
if (projectAccessLevel != null) {
return new AccessRoleWrapper(projectAccessLevel);
}
ProjectAccess groupAccess = permissions.getGroupAccess();
AccessLevel groupAccessLevel = (groupAccess == null) ? null : groupAccess.getAccessLevel();
if (groupAccessLevel != null) {
return new AccessRoleWrapper(groupAccessLevel);
}
}
return null;
} catch (Exception e) {
throw buildException(e, () -> "Failed to get project " + id);
}
}
Aggregations