예제 #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();
    }
  }
예제 #2
0
 @GET
 @Path("/{id}")
 public SourceConfig get(@PathParam("id") String inId) {
   try {
     return this.etlClient.getSourceConfig(inId);
   } catch (ClientException ex) {
     if (ex.getResponseStatus() == ClientResponse.Status.NOT_FOUND) {
       throw new HttpStatusException(Status.NOT_FOUND);
     } else {
       throw new HttpStatusException(Status.INTERNAL_SERVER_ERROR, ex);
     }
   }
 }
예제 #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();
    }
  }
예제 #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();
    }
  }