<commit_before>package pl.matsuo.gitlab.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import static org.springframework.http.HttpStatus.*;
import static org.springframework.web.bind.annotation.RequestMethod.*;


/**
 * Created by marek on 04.07.15.
 */
@Controller
@RequestMapping("/gl")
public class GitlabProxyController {


  @Value("#{environment.PRIVATE_TOKEN}")
  private String gitlabPrivateToken;
  @Value("#{environment.GITLAB_SERVER}")
  private String gitlabServer;


  @RequestMapping(value = "/projects/{user}/{project}/issues", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectIssues(@PathVariable("user") String user,
                       @PathVariable("project") String project,
                       @RequestParam(value = "labels", required = false) String labels,
                       @RequestParam(value = "status", required = false) String status,
                       @RequestParam(value = "milestone", required = false) String milestone) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/issues?"
        + (labels != null ? "labels=" + labels + "&" : "")
        + (status != null ? "status=" + status + "&" : "")
        + (milestone != null ? "milestone=" + milestone + "&" : ""));
  }



  @RequestMapping(value = "/projects/{user}/{project}/milestones/{idMilestone}", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectMilestones(@PathVariable("user") String user,
		                       @PathVariable("project") String project,
                           @PathVariable("idMilestone") Integer idMilestone) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/milestones/" + idMilestone);
  }


  @RequestMapping(value = "/projects/{idProject}/issues/{idIssue}/notes", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectNotes(@PathVariable("idProject") Integer idProject,
                      @PathVariable("idIssue") Integer idIssue) {
    return sendGet(gitlabServer + "/api/v3/projects/" + idProject + "/issues/" + idIssue + "/notes");
  }


  // HTTP GET request
  private String sendGet(String url) {
    try {
      URL obj = new URL(url);<commit_msg>Fix loading milestones<commit_after>package pl.matsuo.gitlab.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import static org.springframework.http.HttpStatus.*;
import static org.springframework.web.bind.annotation.RequestMethod.*;


/**
 * Created by marek on 04.07.15.
 */
@Controller
@RequestMapping("/gl")
public class GitlabProxyController {


  @Value("#{environment.PRIVATE_TOKEN}")
  private String gitlabPrivateToken;
  @Value("#{environment.GITLAB_SERVER}")
  private String gitlabServer;


  @RequestMapping(value = "/projects/{user}/{project}/issues", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectIssues(@PathVariable("user") String user,
                       @PathVariable("project") String project,
                       @RequestParam(value = "labels", required = false) String labels,
                       @RequestParam(value = "status", required = false) String status,
                       @RequestParam(value = "milestone", required = false) String milestone) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/issues?"
        + (labels != null ? "labels=" + labels + "&" : "")
        + (status != null ? "status=" + status + "&" : "")
        + (milestone != null ? "milestone=" + milestone + "&" : ""));
  }



  @RequestMapping(value = "/projects/{user}/{project}/milestones", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectMilestones(@PathVariable("user") String user,
		                       @PathVariable("project") String project) {
    return sendGet(gitlabServer + "/api/v3/projects/" + user + "%2F" + project + "/milestones");
  }


  @RequestMapping(value = "/projects/{idProject}/issues/{idIssue}/notes", method = GET)
  @ResponseStatus(OK)
  public @ResponseBody
  String projectNotes(@PathVariable("idProject") Integer idProject,
                      @PathVariable("idIssue") Integer idIssue) {
    return sendGet(gitlabServer + "/api/v3/projects/" + idProject + "/issues/" + idIssue + "/notes");
  }


  // HTTP GET request
  private String sendGet(String url) {
    try {
      URL obj = new URL(url);
{'fraction_non_alphanumeric': 0.13792463337664748, 'fraction_numerical': 0.0040839056989047705, 'mean_word_length': 3.6892950391644908, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1919170', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1464, 'n_words': 311}