use of org.gitlab4j.api.models.ProjectFilter in project catma by forTEXT.
the class GitlabManagerRestricted method getResourcePermissions.
private Map<String, AccessLevel> getResourcePermissions(Integer groupId) throws GitLabApiException {
Map<String, AccessLevel> resultMap = Maps.newHashMap();
ProjectApi projectApi = new ProjectApi(restrictedGitLabApi);
logger.info("Loading project permissions");
List<Project> resourceAndContainerProjects = projectApi.getProjects(new ProjectFilter().withMembership(true));
logger.info(String.format("Filtering %1$d resources on group #%2$d", resourceAndContainerProjects.size(), groupId));
Set<Project> filteredOnGroupProjects = resourceAndContainerProjects.stream().filter(p -> p.getNamespace().getId().equals(groupId)).collect(Collectors.toSet());
logger.info(String.format("Updating accesslevel registry for %1$d resources", filteredOnGroupProjects.size()));
for (Project p : filteredOnGroupProjects) {
Permissions permission = p.getPermissions();
if (permission.getGroupAccess() != null) {
resultMap.put(p.getName(), permission.getGroupAccess().getAccessLevel());
}
if (permission.getProjectAccess() != null && (!resultMap.containsKey(p.getName()) || resultMap.get(p.getName()).value.intValue() < permission.getProjectAccess().getAccessLevel().value.intValue())) {
resultMap.put(p.getName(), permission.getProjectAccess().getAccessLevel());
}
}
return resultMap;
}
use of org.gitlab4j.api.models.ProjectFilter in project octane-gitlab-service by MicroFocus.
the class GitlabServices method getJobList.
CIJobsList getJobList() {
CIJobsList ciJobsList = dtoFactory.newDTO(CIJobsList.class);
List<PipelineNode> list = new ArrayList<>();
String projectNames = "";
try {
ProjectFilter filter = new ProjectFilter();
filter.withMinAccessLevel(AccessLevel.MAINTAINER);
List<Project> projectsFilters = gitLabApi.getProjectApi().getProjects(filter);
log.info("There are only " + projectsFilters.size() + " projects with access level => MAINTAINER for the integrated user");
for (Project project : projectsFilters) {
try {
ParsedPath parseProject = new ParsedPath(project, gitLabApi);
PipelineNode buildConf;
if (parseProject.isMultiBranch()) {
buildConf = dtoFactory.newDTO(PipelineNode.class).setJobCiId(parseProject.getJobCiId(true)).setName(project.getNameWithNamespace()).setMultiBranchType(MultiBranchType.MULTI_BRANCH_PARENT);
} else {
buildConf = dtoFactory.newDTO(PipelineNode.class).setJobCiId(parseProject.getJobCiId(false)).setName(project.getNameWithNamespace());
}
projectNames = projectNames + buildConf.getName() + ",";
list.add(buildConf);
} catch (Exception e) {
log.warn("Failed to add some tags to the job list", e);
}
}
} catch (Exception e) {
log.warn("Failed to add some jobs to the job list", e);
}
log.info("getJobList results:" + projectNames);
ciJobsList.setJobs(list.toArray(new PipelineNode[list.size()]));
return ciJobsList;
}
Aggregations