protected String getRallyXML(String apiUrl) throws Exception { String responseXML = ""; DefaultHttpClient httpClient = new DefaultHttpClient(); Base64 base64 = new Base64(); String encodeString = new String(base64.encode((rallyApiHttpUsername + ":" + rallyApiHttpPassword).getBytes())); HttpGet httpGet = new HttpGet(apiUrl); httpGet.addHeader("Authorization", "Basic " + encodeString); HttpResponse response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); if (entity != null) { InputStreamReader reader = new InputStreamReader(entity.getContent()); BufferedReader br = new BufferedReader(reader); StringBuilder sb = new StringBuilder(); String line = ""; while ((line = br.readLine()) != null) { sb.append(line); } responseXML = sb.toString(); } log.debug("responseXML=" + responseXML); return responseXML; }
public StringBuilder listToCSVForUserView(List list) { StringBuilder csv = new StringBuilder(); csv.append( "Project,Iteration,Work Product,Name,State,Owner,Task Estimate,Task Remaining,Time Spent\n"); for (int i = 0; i < list.size(); i++) { Map map = (Map) list.get(i); String projectName = (String) map.get("projectName"); String iterationName = (String) map.get("iterationName"); String formattedId = (String) map.get("taskFormattedId"); String taskName = (String) map.get("taskName"); String taskState = (String) map.get("taskState"); String owner = (String) map.get("owner"); String taskEstimate = (String) map.get("taskEstimate"); String taskRemaining = (String) map.get("taskRemaining"); String taskTimeSpent = (String) map.get("hours"); if (taskEstimate == null) { taskEstimate = ""; } if (taskRemaining == null) { taskRemaining = ""; } csv.append("" + projectName + ","); csv.append("\"" + iterationName + "\","); csv.append(formattedId + ","); csv.append(taskName + ","); csv.append(taskState + ","); csv.append(owner + ","); csv.append(taskEstimate + ","); csv.append(taskRemaining + ","); csv.append(taskTimeSpent + "\n"); } return csv; }
public String getEntityString(HttpEntity entity) throws Exception { StringBuilder sb = new StringBuilder(); if (entity != null) { InputStreamReader reader = new InputStreamReader(entity.getContent()); BufferedReader br = new BufferedReader(reader); String line = ""; while ((line = br.readLine()) != null) { sb.append(line); } } return sb.toString(); }
public String loadStream(InputStream is) { StringBuilder sb = new StringBuilder(); try { InputStreamReader reader = new InputStreamReader(is); BufferedReader br = new BufferedReader(reader); String line = ""; while ((line = br.readLine()) != null) { sb.append(line); } } catch (Exception e) { log.error("", e); } return sb.toString(); }
public StringBuilder listToCSV(List list) { StringBuilder csv = new StringBuilder(); csv.append( "Work Product,,Name,State,Owner,Plan Estimate,Task Estimate,Task Remaining,Time Spent\n"); for (int i = 0; i < list.size(); i++) { Map map = (Map) list.get(i); String type = (String) map.get("type"); String formattedId = (String) map.get("formattedId"); String name = (String) map.get("name"); String taskStatus = (String) map.get("taskStatus"); String owner = (String) map.get("owner"); String planEstimate = (String) map.get("planEstimate"); String taskEstimateTotal = (String) map.get("taskEstimateTotal"); String taskRemainingTotal = (String) map.get("taskRemainingTotal"); String taskTimeSpentTotal = (String) map.get("taskTimeSpentTotal"); if ("task".equals(type)) { csv.append("," + formattedId + ","); } else if ("userstory".equals(type)) { csv.append(formattedId + ",,"); } else if ("iteration".equals(type)) { csv.append(",,"); } if (planEstimate == null) { planEstimate = ""; } if (taskEstimateTotal == null) { taskEstimateTotal = ""; } if (taskRemainingTotal == null) { taskRemainingTotal = ""; } csv.append("\"" + name + "\","); csv.append(taskStatus + ","); csv.append(owner + ","); csv.append(planEstimate + ","); csv.append(taskEstimateTotal + ","); csv.append(taskRemainingTotal + ","); csv.append(taskTimeSpentTotal + "\n"); } return csv; }