Example #1
4
  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;
  }
Example #2
0
  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();
  }
Example #3
0
  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 void run() {
    try {
      PrintWriter pw = null;
      if (os != null) pw = new PrintWriter(os);

      InputStreamReader isr = new InputStreamReader(is);
      BufferedReader br = new BufferedReader(isr);
      String line = null;
      while ((line = br.readLine()) != null) {
        if (pw != null) pw.println(line);
        logger.info(type + ">" + line);
      }
      if (pw != null) pw.flush();
    } catch (IOException ioe) {
      logger.fatal("IOE: ", ioe);
    }
  }
Example #5
0
 private CIJob getJob(ApplicationInfo appInfo) throws PhrescoException {
   Gson gson = new Gson();
   try {
     BufferedReader br = new BufferedReader(new FileReader(getCIJobPath(appInfo)));
     CIJob job = gson.fromJson(br, CIJob.class);
     br.close();
     return job;
   } catch (FileNotFoundException e) {
     S_LOGGER.debug(e.getLocalizedMessage());
     return null;
   } catch (com.google.gson.JsonParseException e) {
     S_LOGGER.debug("it is already adpted project !!!!! " + e.getLocalizedMessage());
     return null;
   } catch (IOException e) {
     S_LOGGER.debug(e.getLocalizedMessage());
     return null;
   }
 }
Example #6
0
 public List<CIJob> getJobs(ApplicationInfo appInfo) throws PhrescoException {
   S_LOGGER.debug("GetJobs Called!");
   try {
     boolean adaptedProject = adaptExistingJobs(appInfo);
     S_LOGGER.debug("Project adapted for new feature => " + adaptedProject);
     Gson gson = new Gson();
     BufferedReader br = new BufferedReader(new FileReader(getCIJobPath(appInfo)));
     Type type = new TypeToken<List<CIJob>>() {}.getType();
     List<CIJob> jobs = gson.fromJson(br, type);
     br.close();
     return jobs;
   } catch (FileNotFoundException e) {
     S_LOGGER.debug("FileNotFoundException");
     return null;
   } catch (IOException e) {
     S_LOGGER.debug("IOException");
     throw new PhrescoException(e);
   }
 }
  /**
   * Builds a SgrScoreCalculator object
   *
   * @param data - name of file containing sgr data
   * @param winSize - size of display window
   * @throws IOException - if the file cannot be accessed
   */
  public SgrScoreCalculator(String data, int winSize, CurationSet curation) throws IOException {
    super(winSize);
    BufferedReader br = new BufferedReader(new FileReader(data));
    String line;
    double minAbsScore = Double.POSITIVE_INFINITY;
    Set<String> unmatchedIds = new HashSet<String>();
    while ((line = br.readLine()) != null) {
      String[] tokens = line.split("\t");
      String refId = curation.getRefSequence().getName();
      if (!tokens[0].equals(refId)) {
        if (!unmatchedIds.contains(tokens[0])) {
          logger.warn(
              "Score id "
                  + tokens[0]
                  + " does not match main sequence id "
                  + refId
                  + ". Skipping score.");
          unmatchedIds.add(tokens[0]);
        }
        continue;
      }
      Double score = new Double(Double.parseDouble(tokens[2]));
      // chuck out scores outside of the given range
      int pos = Integer.parseInt(tokens[1]);
      if (pos >= curation.getLow() && pos <= curation.getHigh()) {
        scoreMap.put(pos, score);
      }

      if (Math.abs(score) < minAbsScore) {
        minAbsScore = Math.abs(score);
      }
      if (score.doubleValue() < minScore) {
        minScore = score;
      }
      if (score.doubleValue() > maxScore) {
        maxScore = score;
      }
    }
    while (minAbsScore * factor < 1) {
      factor *= 10;
    }
  }
  public void run() {
    try {
      PrintWriter writer = null;
      if (out != null) {
        writer = new PrintWriter(out);
      }

      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String line = br.readLine();
      while (line != null) {
        if (writer != null) {
          writer.println(line);
        }
        log4JLevel.log(log, line);
        line = br.readLine();
      }
      if (writer != null) {
        writer.flush();
      }
    } catch (IOException e) {
      throw new IoRuntimeException("Exception gobbling stream ", e);
    }
  }