private StringBuilder buildIterationOptions(IterationOptions options, StringBuilder url) { StringBuilder optionString = new StringBuilder(); if (null == options) return url; if (options.getLimit() > 0) optionString .append(HttpUtils.getUrlAppender(optionString)) .append("limit=") .append(options.getLimit()); if (null != options.getOffset()) optionString .append(HttpUtils.getUrlAppender(optionString)) .append("offset=") .append(options.getOffset()); return url.append(optionString); }
private List<Iteration> getIterations(StringBuilder url, IterationOptions options) throws PivotalTrackerException { Iterations iterations = null; int reponseCode = 0; try { HttpURLConnection connection = HttpUtils.makeGetRequest(buildIterationOptions(options, url).toString(), this.apiToken); reponseCode = connection.getResponseCode(); if (reponseCode == HttpURLConnection.HTTP_OK) { JAXBContext context = JAXBContext.newInstance(objfactory.createIterations().getClass()); Unmarshaller unmarshaller = context.createUnmarshaller(); iterations = (Iterations) unmarshaller.unmarshal(connection.getInputStream()); } } catch (Exception e) { throw new PivotalTrackerException(reponseCode, "Response was not successfull."); } return iterations.getIteration(); }