Exemple #1
0
  @Override
  protected void doPost(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
      throws ServletException, IOException {

    LOGGER.debug("ProxyServlet - POST");

    StringBuilder stringBuilder = new StringBuilder(1000);
    Scanner scanner = new Scanner(servletRequest.getInputStream());
    while (scanner.hasNextLine()) {
      stringBuilder.append(scanner.nextLine());
    }
    LOGGER.debug("json: {}", stringBuilder.toString());
    StringBuilder uri = new StringBuilder(500);
    uri.append(getTargetUri());
    // Handle the path given to the servlet
    if (servletRequest.getPathInfo() != null) { // ex: /my/path.html
      uri.append(servletRequest.getPathInfo());
    }
    LOGGER.debug("uri: {}", uri.toString());
    try {
      servicesClient.proxyPost(uri.toString(), stringBuilder.toString());
    } catch (ClientException e) {
      e.printStackTrace();
    }
  }
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    List<JsonTreeData> cohortList = new ArrayList<>();
    try {
      DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
      List<CohortDestination> destinations = servicesClient.getCohortDestinations();
      for (Destination dest : destinations) {
        JsonTreeData cohortJson = createData(dest.getName(), dest.getName());
        cohortJson.setKeyVal("displayName", dest.getName());
        cohortJson.setKeyVal("description", dest.getDescription());
        Date createdAt = dest.getCreatedAt();
        cohortJson.setKeyVal("createdDate", createdAt != null ? df.format(createdAt) : null);
        Date updatedAt = dest.getUpdatedAt();
        cohortJson.setKeyVal("lastModifiedDate", updatedAt != null ? df.format(updatedAt) : null);
        cohortList.add(cohortJson);
      }
    } catch (ClientException ex) {
      throw new ServletException(ex);
    }
    /*JsonTreeData cohort = createData("lymphoma-iCD9","lymphoma-iCD9");
    cohort.setKeyVal("displayName","lymphoma-iCD9");
    cohort.setKeyVal("description","The cohort defined for lymphoma based on ICD9 codes");
    cohort.setKeyVal("createdDate","07/04/2014");
    cohort.setKeyVal("lastModifiedDate","07/04/2014");
    cohort.setKeyVal("currentlyActive","");
    cohortList.add(cohort);
    cohort=createData("lymphoma-labs","lymphoma-labs");
    cohort.setKeyVal("displayName","lymphoma-labs");
    cohort.setKeyVal("description","The cohort defined for lymphoma based on labs performed");
    cohort.setKeyVal("createdDate","07/02/2014");
    cohort.setKeyVal("lastModifiedDate","07/05/2014");
    cohort.setKeyVal("currentlyActive","Yes");
    cohortList.add(cohort);
    cohort=createData("lung-codes","lung-codes");
    cohort.setKeyVal("displayName","lung-codes");
    cohort.setKeyVal("description","The cohort defined for lung based on procedure and icd9 codes");
    cohort.setKeyVal("createdDate","07/03/2014");
    cohort.setKeyVal("lastModifiedDate","07/15/2014");
    cohort.setKeyVal("currentlyActive","");
    cohortList.add(cohort);*/
    req.setAttribute("cohorts", cohortList);
    req.getRequestDispatcher("/protected/cohort_home.jsp").forward(req, resp);
  }
Exemple #3
0
  @Override
  protected void doDelete(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
      throws ServletException, IOException {

    LOGGER.debug("ProxyServlet - DELETE");

    StringBuilder uri = new StringBuilder(500);
    uri.append(getTargetUri());
    // Handle the path given to the servlet
    if (servletRequest.getPathInfo() != null) { // ex: /my/path.html
      uri.append(servletRequest.getPathInfo());
    }
    LOGGER.debug("uri: {}", uri.toString());

    try {
      servicesClient.proxyDelete(uri.toString());
    } catch (ClientException e) {
      e.printStackTrace();
    }
  }
Exemple #4
0
  @Override
  protected void doGet(HttpServletRequest servletRequest, HttpServletResponse servletResponse)
      throws ServletException, IOException {

    LOGGER.debug("ProxyServlet - GET");

    StringBuilder uri = new StringBuilder(500);
    uri.append(getTargetUri());
    // Handle the path given to the servlet
    if (servletRequest.getPathInfo() != null) { // ex: /my/path.html
      uri.append(servletRequest.getPathInfo());
    }
    LOGGER.debug("uri: " + uri.toString());
    try {
      String response =
          servicesClient.proxyGet(
              uri.toString(), getQueryParamsFromURI(servletRequest.getParameterMap()));
      servletResponse.getWriter().write(response);
    } catch (ClientException e) {
      e.printStackTrace();
    }
  }