Пример #1
0
  @Override
  public void service(ServletRequest request, ServletResponse response)
      throws ServletException, IOException {

    String mitabUrl = request.getParameter("mitabUrl");

    String url = mitabUrl.substring(0, mitabUrl.lastIndexOf("/"));
    String query = mitabUrl.substring(mitabUrl.lastIndexOf("/"));

    if (query != null) {
      query = UrlUtils.encodeUrl(query);

      String encodedUrl = url + query;

      if (log.isDebugEnabled()) log.debug("encodedUrl: " + encodedUrl);

      final URL inputUrl = new URL(encodedUrl);
      final InputStream is = inputUrl.openStream();

      ServletOutputStream stream = response.getOutputStream();
      try {
        response.setContentType("text/plain");

        final Tab2Cytoscapeweb tab2Cytoscapeweb = new Tab2Cytoscapeweb();

        String output = null;
        try {
          output = tab2Cytoscapeweb.convert(is);
        } catch (PsimiTabException e) {
          throw new IllegalStateException("Could not parse input MITAB.", e);
        }
        stream.write(output.getBytes());
        stream.flush();
      } finally {
        is.close();
      }
    }
  } // We don't have url