use of com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonMultipleObjectsDeserializer in project intellij-community by JetBrains.
the class GitlabRepository method fetchProjects.
/**
* Always forcibly attempts do fetch new projects from server.
*/
@NotNull
public List<GitlabProject> fetchProjects() throws Exception {
final ResponseHandler<List<GitlabProject>> handler = new GsonMultipleObjectsDeserializer<>(GSON, LIST_OF_PROJECTS_TYPE);
final String projectUrl = getRestApiUrl("projects");
final List<GitlabProject> result = new ArrayList<>();
int pageNum = 1;
while (true) {
final URI paginatedProjectsUrl = new URIBuilder(projectUrl).addParameter("page", String.valueOf(pageNum)).addParameter("per_page", "30").build();
final List<GitlabProject> page = getHttpClient().execute(new HttpGet(paginatedProjectsUrl), handler);
// Gitlab's REST API doesn't allow to know beforehand how many projects are available
if (page.isEmpty()) {
break;
}
result.addAll(page);
pageNum++;
}
myProjects = result;
return Collections.unmodifiableList(myProjects);
}
use of com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonMultipleObjectsDeserializer in project intellij-community by JetBrains.
the class GitlabRepository method fetchIssues.
@NotNull
public List<GitlabIssue> fetchIssues(int pageNumber, int pageSize, boolean openedOnly) throws Exception {
ensureProjectsDiscovered();
final URIBuilder uriBuilder = new URIBuilder(getIssuesUrl()).addParameter("page", String.valueOf(pageNumber)).addParameter("per_page", String.valueOf(pageSize)).addParameter("order_by", "updated_at");
if (openedOnly) {
// Filtering by state was added in v7.3
uriBuilder.addParameter("state", "opened");
}
final ResponseHandler<List<GitlabIssue>> handler = new GsonMultipleObjectsDeserializer<>(GSON, LIST_OF_ISSUES_TYPE);
return getHttpClient().execute(new HttpGet(uriBuilder.build()), handler);
}
Aggregations