Search in sources :

Example 1 with GsonSingleObjectDeserializer

use of com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer in project intellij-community by JetBrains.

the class GitlabRepository method fetchIssue.

/**
   * @param issueId global issue's ID (<tt>id</tt> field, not <tt>iid</tt>)
   */
@Nullable
public GitlabIssue fetchIssue(int projectId, int issueId) throws Exception {
    ensureProjectsDiscovered();
    final HttpGet request = new HttpGet(getRestApiUrl("projects", projectId, "issues", issueId));
    final ResponseHandler<GitlabIssue> handler = new GsonSingleObjectDeserializer<>(GSON, GitlabIssue.class, true);
    return getHttpClient().execute(request, handler);
}
Also used : GsonSingleObjectDeserializer(com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer) HttpGet(org.apache.http.client.methods.HttpGet) GitlabIssue(com.intellij.tasks.gitlab.model.GitlabIssue) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with GsonSingleObjectDeserializer

use of com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer in project intellij-community by JetBrains.

the class RedmineRepository method fetchProjects.

public List<RedmineProject> fetchProjects() throws Exception {
    HttpClient client = getHttpClient();
    // Download projects with pagination (IDEA-125056, IDEA-125157)
    List<RedmineProject> allProjects = new ArrayList<>();
    int offset = 0;
    ProjectsWrapper wrapper;
    do {
        HttpGet method = new HttpGet(getProjectsUrl(offset, 50));
        wrapper = client.execute(method, new GsonSingleObjectDeserializer<>(GSON, ProjectsWrapper.class));
        offset += wrapper.getProjects().size();
        allProjects.addAll(wrapper.getProjects());
    } while (wrapper.getTotalCount() > allProjects.size() || wrapper.getProjects().isEmpty());
    myProjects = allProjects;
    return Collections.unmodifiableList(myProjects);
}
Also used : GsonSingleObjectDeserializer(com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer) RedmineProject(com.intellij.tasks.redmine.model.RedmineProject) HttpClient(org.apache.http.client.HttpClient) HttpGet(org.apache.http.client.methods.HttpGet) ArrayList(java.util.ArrayList)

Aggregations

GsonSingleObjectDeserializer (com.intellij.tasks.impl.httpclient.TaskResponseUtil.GsonSingleObjectDeserializer)2 HttpGet (org.apache.http.client.methods.HttpGet)2 GitlabIssue (com.intellij.tasks.gitlab.model.GitlabIssue)1 RedmineProject (com.intellij.tasks.redmine.model.RedmineProject)1 ArrayList (java.util.ArrayList)1 HttpClient (org.apache.http.client.HttpClient)1 Nullable (org.jetbrains.annotations.Nullable)1